• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient and SerialPort

lexus21

Active Member
Joined
Dec 14, 2022
Messages
86
Reaction score
25
I'm using OTClient v8 and I have a device that uses a COM port.
I want to integrate otc to read this COM.
How to read COM port using LUA?
Can LUA handle reading data from COM?

Or is it better to handle the COM port from C++?



Maybe there are other "pros and cons" that I don't know about.
Regards
 
Last edited:
Or is it better to handle the COM port from C++?
I got no idea about implementations of COM in Lua/C++ libraries, but read/write operations may be 'blocking'.
If you 'block' Lua script - make it wait for date send/receive over COM -, it will freez whole OTC.
That's why it would be safer to add it in C++. If read/write operations will block C++ thread, you can easily fix it by adding extra thread to communicate over COM.
 
I think it is better to handle it in C++. You can use boost.asio for that, there is support for non-blocking operations

Just a bit curious: what are you trying to do? use a joystick to play?
 
In the near future I will create a separate post about what I have planned, but I can already let you in on the secret and it will be related to meditation :)
 
Last edited:
Back
Top