December 13th, 2013, 03:56 AM
Serial communication in windows - ClearCommError finds no data in read buffer
I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.
This is the relevant code in my desktop:
if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL);
The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.
The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!