I have a system where I see strange behavior with serial ports that I do not expect. Previously, I saw this with usb-to-serial adapters, but now I see it on my native serial ports with a much higher frequency.
The system is configured to run automatic tests and will first perform some tasks that cause a large amount of data to be output from the serial device, while I do not have open ports. The device will also reset. Only tx / rx lines are connected. No flow control.
After completing these tasks, the test software opens the serial ports and immediately crashes because it receives unexpected responses. When I reproduced this, I found that if I open the serial port in the terminal program, I will see that a few kilobytes of old data (which, it seems, were sent when the port was closed), immediately disappeared. As soon as I close this program, I can run the tests as expected.
What can happen? How does Linux handle serial port buffering when the device is closed? If I opened the device, made it send the output, and then closed it without reading it, would that cause the same problem?
source share