Reputation: 443
I just finished a small project written in C, where I read a data stream from a serial port and parse the incoming data. The software is written for POSIX systems (using termios) and follows the standard steps to working with serial i/o
Other than the socket parts, the code is straight ANSI C.
My question is, how involved would it be to make the code work on a windows platform. The port would not be written by me, I'd only like to give an indication to others who might be interested in porting it (i.e. trivial, not so trivial, rip your eyes out insanity inducing).
Also if someone has Windows with "Windows Services for UNIX", would they be able to use the code without modifying it?
So, if anyone has experience with this could you please share.
Upvotes: 3
Views: 2850
Reputation: 24887
It should be pretty easy to do. The names are very different, but the sequence of calls and concepts are very similar.
What you are looking for is the DCB structure which should be used with the SetComState() function to set baudrate, stopbits etc. Then use SetCommTimeouts() and set the timeout values in the COMMTIMEOUTS structure to make subsequent read calls blocking.
Here is a short introduction as a pretty PDF. (Backup.)
Upvotes: 3