I have spent about two days tracking down an issue in one of my machines. I
am streaming pressure readings from an i2c pressure sensor to a PC at high
speed. I have reduced the problem to a small test case. To replicate the
fault I connect the beaglebone black to a PC, connect to it with serial
over the micro USB port, login and launch a command that streams data fast.
On the PC run a program that collects the streamed data more slowly than it
is being created.
import serial
x = serial.Serial('COM15')
to_send = b'\x03yes HelloWorld\n'
x.write(to_send)
while True:
received = x.readline()
if received != b'HelloWorld\r\n':
print(received)
The python program above prints lines like:
b'ld\r\n'
b'HelloWoroWorld\r\n'
b'HelloWorldorld\r\n'
b'HelloWorldorld\r\n'
b'ld\r\n'
b'ld\r\n'
b'ld\r\n'
b'ld\r\n'
b'ld\r\n'
b'ld\r\n'
b'HelloWoroWorld\r\n'
b'ld\r\n'
b'HelloWlloWorld\r\n'
b'ld\r\n'
b'HelloWorldorld\r\n'
At about 4 lines per second. If I set the program on the beagle bone to
stream slowly then this issue goes away. It appears to be an issue with a
buffer filling up somewhere between the output of the yes command and
reading bytes from the windows API. The correct behaviour is that the yes
command should be stopped when the buffer is full to prevent the loss of
data, then allowed to continue when there is space in the buffer again. I
observe that the streaming command (in this case yes) is stopped but there
is still data loss happening somewhere.
I wrote this in python because it is the language I am most comfortable in
but if you needed me to I could rewrite the example in some other language.
To run the program shown above you will need pyserial and you will need to
change 'COM15' to be whatever the port is called on your computer.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/d63ea012-b3ea-49b6-9b13-f3e3be9c51ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.