Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rx buffer overrun. #102

Open
eslavko opened this issue Apr 11, 2016 · 3 comments
Open

rx buffer overrun. #102

eslavko opened this issue Apr 11, 2016 · 3 comments

Comments

@eslavko
Copy link

eslavko commented Apr 11, 2016

Hello..
Maybe this is not best place for my trouble but don't know better one.
I have hardware with FTDI FT230XU chip which have internal 512 byte fifo. And I need to read a lot of data fast. So the baud rate is set at 2000000bps(want even faster but there are hardware limitation).
So internal buffer is filled in aprox 2.5 milisecond. And pyserial seems to have own buffer 4096 bytes long. So total time to fill buffers is around 20 mili second.
Now the trouble. If I sit in the blocking loop until data block of 256kb is received - aprox 1.3 second I got data ok. But that is blocking loop and gui is not responsive that time. If I put that in thread loop sometime I got ok data sometime not. Lattency seems to be just around 4096 bytes (20ms). Is there a way to increase read buffer? So I can do unblocking read? If I can expand buffer to 256k should be ideal...
..and must be linux and windows compatible.

Thanks a lot for any god solution.

@zsquareplusc
Copy link
Member

There is no cross platform way to set the serial buffer size. On windows you could use set_buffer_size(). You could also try to use hardware flow control.

@eslavko
Copy link
Author

eslavko commented Apr 25, 2016

Hello...
Have no pins for hardware handshake. So I do implement some kind of software handshake (XON/XOFF doesn't work.. Seems that XOF is sended when buffer is full but my hardware have 3 bytes fifo and I got lost last byte with XON XOF)
So I implement protocol as.
-PC clear all buffers and send command to device to send 128kb pseudo random byte sequence.
-PC wait one second. (the transmission is done earlier)
-PC read serial buffer and bytes received should be buffer length (I got 3000 to 4092 bytes depending of computer)
-PC checks if buffer data match and if it match then transmission block is set as received len.
the real transmission is then done in chunks of buffer len.
-The PC send read command
-Host send buffer len bytes
-PC after time read buffer and send ACK byte
-Host receive ack byte and send next block.
....and that is all.

@jcmarsh
Copy link

jcmarsh commented Jan 25, 2018

I'm also running into a problem with the buffer size... it would be really helpful to have a way to set the size in Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants