Roger Oberholtzer <roger@opq.se> wrote:
I feel funny even asking the following, but I have a situation that I need to resolve.
1. When opening a serial port on Linux, the very first read() will only return data that arrived from the point of the open. That is, any data in kernel buffers will not be seen. Right?
Just to be sure, we do a flush after the open:
tcflush(serialPort, TCIOFLUSH);
So, is there any chance we see data from before the open/flush() call?
2. Similar question about opening a TCP/IP socket. Could we expect to see any data that arrived before the connect() call? Is there any need to flush the socket?
The reason I ask is that I have two devices that provide time tagged data. One is a Trimble GPS receiver on a serial port. The other is a data collection device (time-synced with its own GPS receiver) on a TCP/IP socket. It is expected that the two, when opened, should be reporting rather similar times. Unfortunately, the two differ by up to 20 seconds. It seems that the trend is that the network device starts out 20 seconds in the future relative to the serial port device.
My suspicion is that the data collection device is not syncing properly with it's own GPS receiver. Before I complain to the manufacturer, I want to be certain I have not missed something.
Roger, For rs-232 there is no kernel level concept of a connection. I don't know what the receiver does if data comes in without a open file handle, but the sending side can only send it or queue it up. If you are using rts/cts hardware flow control the data could easily be sitting in the sending device until you open the tty and raise cts. You need to some how flush the output queue of the sender in that case. If you have a rs-232 monitor you should use it to see exactly what is going on. (I did tons of rs-232 work in the '90s, but nothing in the last 10 years.) For sockets, there are not any kernel level queues on either side until the connection is established. Greg -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org