lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>However, I am 
>not assuming that platform portability is a very high priority 
>feature.
>

Platform portability should not be a major issue. Since Windows uses the simple ReadFile/WriteFile technique to work with serial ports, as does most other OSes, a couple of #ifdefs or macros should solve most of the problems:

#ifdef WIN32
#define SendCommData(h, b) do { SendFile(...); } while(0);
#else
#define SendCommData(h, b) do { fwrite(...); } while(0);
#endif

etc. Naturally "h" would be the handle to the file descriptor (in WIN32, a HANDLE; in others, a FILE* or int, depending on how you do things). The general idea behind Windows's serial communication is extremely parallel to other OSes, it just has different names. That should simplify things greatly so long as you pay attention while you're writing it.

-- Matthew P. Del Buono