Data not received properly using COM Port [modified]
-
Hi, Iam sending data to ComPort and using RS-232 cable Iam trying to receive the data at the other end. I set the properties also(BaudRate,Stop Bits,Parity etc..)both at sender and receiver. Sending End: char dataToSend[100]; dataToSend = "asdfsdf ...."; result = WriteFile(handlePort,dataToSend,99,&length,NULL); Receiving End: char dataReceived[100]; result = ReadFile(handlePort,dataReceived,99,&length,NULL); cout << "Data Received = " << dataReceived<
-
Hi, Iam sending data to ComPort and using RS-232 cable Iam trying to receive the data at the other end. I set the properties also(BaudRate,Stop Bits,Parity etc..)both at sender and receiver. Sending End: char dataToSend[100]; dataToSend = "asdfsdf ...."; result = WriteFile(handlePort,dataToSend,99,&length,NULL); Receiving End: char dataReceived[100]; result = ReadFile(handlePort,dataReceived,99,&length,NULL); cout << "Data Received = " << dataReceived<
Ayesha Farheen wrote:
result = ReadFile(handlePort,dataReceived,99,&length,NULL);
What is the value of
result
? If it isFALSE
, what is the return value ofGetLastError()
? What is the value oflength
?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
Ayesha Farheen wrote:
result = ReadFile(handlePort,dataReceived,99,&length,NULL);
What is the value of
result
? If it isFALSE
, what is the return value ofGetLastError()
? What is the value oflength
?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
At both sending and receiving ends , its returning 1 (TRUE). Ayesha
-
At both sending and receiving ends , its returning 1 (TRUE). Ayesha
-
Before sending the data or receiving it , Iam flushing the buffer using following method. int nReturnValue = PurgeComm(handlePort_,PURGE_TXCLEAR | PURGE_RXCLEAR); And the return value is non-zero, i.e flushing succeded. I checked both, with and without PurgeComm(). But still its not working.i.e Output is same for both. And the length received is coming as 0. I didnt understand one thing, Iam sending the data only ones, but why its receiving it those many times and why data is not coming? Thank You. Ayesha -- modified at 2:54 Tuesday 11th July, 2006
-
Hi, Iam sending data to ComPort and using RS-232 cable Iam trying to receive the data at the other end. I set the properties also(BaudRate,Stop Bits,Parity etc..)both at sender and receiver. Sending End: char dataToSend[100]; dataToSend = "asdfsdf ...."; result = WriteFile(handlePort,dataToSend,99,&length,NULL); Receiving End: char dataReceived[100]; result = ReadFile(handlePort,dataReceived,99,&length,NULL); cout << "Data Received = " << dataReceived<
-
Ayesha wrote:
result = WriteFile(handlePort,parameterNCheckSumData,99,&length,NULL);
What is parameterNCheckSumData? Should'nt it be dataToSend. Adios, Cool Ju :cool: Dream Ur DestinyYes , that is dataToSend its not parameterNCheckSumData. But thats just a char buffer name. I want to know why data is not being received properly. Thanku You. Ayesha
-
Yes , that is dataToSend its not parameterNCheckSumData. But thats just a char buffer name. I want to know why data is not being received properly. Thanku You. Ayesha
-
Before sending the data or receiving it , Iam flushing the buffer using following method. int nReturnValue = PurgeComm(handlePort_,PURGE_TXCLEAR | PURGE_RXCLEAR); And the return value is non-zero, i.e flushing succeded. I checked both, with and without PurgeComm(). But still its not working.i.e Output is same for both. And the length received is coming as 0. I didnt understand one thing, Iam sending the data only ones, but why its receiving it those many times and why data is not coming? Thank You. Ayesha -- modified at 2:54 Tuesday 11th July, 2006
Flush the buffer after sending the data using FlushFileBuffers. This ensures that nothing gets stuck in a buffer waiting to send. If you are sending the data only once but the remote end is receiving it many times, make sure you have your line enders right -- it could be that the remote end is getting confused. Try 13 10, just 10, and just 13 -- I can never remember which of those are the usual line enders. earl