Click to See Complete Forum and Search --> : Serial Communications


ROOKIE
April 14th, 1999, 02:01 PM
I am attempting to write to and read from the serial port using the CreateFile function. This works fine when I am writing to the port, but when I should be seeing data coming back in, I don't get anything. I set the timeouts and the function returns, but the number of bytes read is always zero. I don't understand why this isn't working. I am able to write to the port successfully, which indicates that the baud rate and all of the transmit settings are configured properly. Is there some setting that is only for receiving data that I should look at? Is there some way to see what the error is that is causing my function to not receive data?


ReadFile(
FileIO, // handle of file to read
lpBuffer, // address of buffer that receives data
nNumberOfBytesToRead, // number of bytes to read
&lpNumberOfBytesRead, // address of number of bytes read
NULL // address of structure for data
);

Cathy
April 14th, 1999, 02:50 PM
I couldn't get that to work either. I bought a third party library that works well from a company called MarshallSoft. But I noticed there is a class CSerialPort on this site that you can use for free.

Gomez Addams
April 14th, 1999, 03:44 PM
There is a sample on this site called CommSpy in the Network (?) category.
It might be helpful.

April 14th, 1999, 10:30 PM
If you are using Visual C++ 5.0, you can find the answer in the example code COMM. I used it succesfully in an industrial project application. You just cut and paste the code, then setup the communication paramaters and that's all!. You should understand the code, to adapt it to your own needings. It's very simple.

veena.n
May 6th, 2004, 01:19 AM
can you please tell me where exactly is that example COMM