I have been working on a windows-specific wrapper for the COMM API. My hope is that this could satisfy one of the missing features identified for the Lua for Windows distribution.
My plan is to produce a C module that is the thinnest possible veneer over the Windows API. I am assuming that I don't need to support Unicode, and for the moment that support for asynchronous calls ("overlapped" mode) is not required either.
I would imagine that it would be possible to use this as a core module underneath a portability layer if there really is a good candidate for a platform-portable serial port API. However, I am not assuming that platform portability is a very high priority feature.
I am using SWIG to generate the majority of the wrapper code, so targeting languages other than Lua should be possible as well, althought that is not particularly a priority of mine either.
In addition to providing its own open, close, read, and write functions, it wraps access to BuildCommDCBA(), BuildCommDCBAndTimeoutsA(), ClearCommBreak(), ClearCommError(), CommConfigDialogA(), EscapeCommFunction(), GetCommConfig(), GetCommMask(), GetCommModemStatus(), GetCommProperties(), GetCommState(), GetCommTimeouts(), GetDefaultCommConfig(), PurgeComm(), SetCommBreak(), SetCommConfig(), SetCommMask(), SetCommState(), SetCommTimeouts(), SetDefaultCommConfig(), SetupComm(), and TransmitCommChar(). I also added wrappers to deal with Windows error codes, and to support MessageBoxA() just because it's there. I also had SWIG generate type handlers for the necessary types DCB, COMMCONFIG, COMMPROP, COMMTIMEOUTS, and COMMSTAT.
I intend to get it stable enough for use outside my PC real soon now, and will put it on LuaForge for review "soon".
In the mean time, I'm open to thoughts and suggestions...
Very good news. Can't wait to add this to Lua for Windows.
--