Re: Reading Serial Port
On Jan 30, 7:18 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
You have to treat the serial port as a stream-oriented device. You will g=
et as many bytes
as you get, and it may not be all the bytes you need.
Does this means, that may be I'm receiving data even if device is not
sending me anything?
If you have a data overrun, you will lose characters. Also, is this a pur=
e RS232 network
or is a half-duplex system like RS485 (there are serious issues about RS48=
5 networks)
Is a device that complains RS232 protocol, but a partner says that is
working at half-duplex. (can it be?)
Also, where are you determining this lossage? At the receive site or the =
PostMessage
handler?
I'm outputting data with TRACE here
if( bytesRead>0 )
{
TRACE( "Data readed:%d",buffer );
this->notificador->PostMessage(UWM_DATA_READ,
(WPARAM)buffer);
}
and I found that here data is already losed (bytes ommited in the 16th
frame).
I've used this code at speeds up to 115200bps, without lossage, and I've u=
sed it at 9600
on RS485 multidrop networks but it took a lot of work to avoid data lossag=
e at the line
turnaround event.
I don't see anything here that should result in data lossage, but do you h=
ave any idea
what data was being sent in the 16th frame?
The device is always sending the same frame:
af 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 b9
I found that the firsts bytes I receive are (almost) always garbage or
buffered bites of frames from old sessions of my app... may be here
comes the problem=BF?
I'm wondering if a ^S/^Q or some similar data
sequence caused a problem, although your DCB should preclude this.
What's a ^S/^Q ???
Did you check SetCommState to make sure it worked?
I watched my DCB var before and after SetCommState and the values gets
correct.
I'm desperate...
Maybe this will help: I've made a simple java serial reader and I got
the same problem...
But we have another app that reads the entire bytes coming from serial
port (we are sure of this) and there is no problem with this device!!!!