Reputation: 110
When writing from a laptop to an external serial device that I am using, it is possible for the laptop to be writing faster than the program running on the device can actually clear its serial read buffer, leading to data being lost do to the buffer overflowing.
Is there a way to simulate this behavior using a virtual serial port with socat
? For my testing so far, I have used the following command:
socat -d -d pty,raw,echo=0 pty,raw,echo=0
(For the sake of the example, lets say it creates /dev/pts/2
and /dev/pts/3
, referred to as A
and B
respectively).
Which creates two virtual serial ports that I can send data across. However, if I start writing a large amount of data to A
without reading any from B
, the writing to A
will eventually block until I read from B
and make room in its read buffer.
It is unclear to me whether there is some internal feedback between the read buffer of B
, or if the actual blocking is occurring in the write buffer of A
due to some other internal feedback within whatever socat setup that tells blocks the writing because there is no room in the read buffer of B
.
Is there any way to avoid this blocking and have it overflow the read buffer of B
?
Hopefully my question makes sense. Thank you for the help.
Upvotes: 2
Views: 1869