Serial Communication WIN 2000


Thread Starter

Thomas J. Byrne


I'm a student in Ireland doing a project which involves:
1 LMS lazar scanner,
1 windows 2000 professional pc,
1 copy of MS visual studio 6.0 (I'm gona use VC++ from the studio).

Ok, right, the task at hand is to communicate between the scanner and the pc using the serial port (COM1) (Not too difficult, I have this part working, for anyone reading this who needs help doing this, I've found great articles here on, and also the best one was at: hope this helps someone.) so back to my problem. I need write a program quite like the Hyper Terminal program that comes with windows.

1. The program needs to send settings (Data) to the scanner from the PC
2. Retrieve data from the scanner to the PC

This needs to be done using threads in c++, that's my BIG Problem :-(.

I've opened the com port using

am able to read to the port using
...ReadFile(hSerial, szBuff, NUMBERBYTES, &dwBytesRead, NULL)...

am able to write to the port using

BUT I don't know how to implement this using threads. Is there some way I can start a thread for reading (EG: _beginthread(ReadThread, 0, NULL); ) so it will continuously read the data coming in from the serial port for as long as the program runs, but can be stopped for a time to allow another thread to write to the port?

Some code examples would really help. Please Please Please Help!!

Thank you,


Thomas Byrne
[email protected]

i think you can use one of the synchronization methods to accomplish this. Otherwise use some flag; check it while reading and writing; say 1 for writing & 0 for reading.