LUA Hardware Interfacing and DLL's

Hello! I need to somehow get data from a hardware serial port (win32) to somewhere I can access it with serverside LUA in a timely manner. (yaw/pitch/roll values for a player.SetEyeAngles type thing.)

I haven’t done much LUA but I’m decent with C++. So far I figure my options are:

  1. Write data to a text file then read it from LUA. I can see this being slow and buggy.

  2. Run an external application and try to do this through sockets, adding more lag and drag on the system.

  3. Ideally, make or steal a binary module in C++ that reads the serial port and returns an Angle.

I’ve read through
and gotten the example from
to compile and run, but I haven’t been able to find anything approaching a reference for doing this stuff. Can I just stick raw C++ serial object code into the module? How do I pass data of type Angle back to LUA? Has anyone tried this or similar before?

Any information, help, or links would be greatly appreciated!

Your best bet is doing this with an external applications and web sockets as this is prolly the least hacky way. OR you fix up one of the serial port modules for the standard lua and make it works with gmod.