Basic serial port communication is simple. Use
CreateFile()
to open the port,
SetCommState()
to configure it (baud rate, data size, stop bits, flow control, etc), and
ReadFile()
and
WriteFile()
for IO operations. See the above functions in the MSDN and
Communications Functions[
^].
But serial IO is usually asynchronous and transferring larger amounts of data with slow connections would block your program. Therefore, serial IO should be performed by worker threads using overlapped IO. Similar handling is used with network socket programming. So you might have some knowledge already.
I suggest to use the simple method first to ensure that the communication with your device is working. Then implement overlapped IO and worker threads if necessary. What and how to implement depends on your device (baud rate, amount of data, when data are send and received).