-
Notifications
You must be signed in to change notification settings - Fork 48
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
Byte transmission problem when using big buffer #26
Comments
The read and write paths in the C code are coupled, so even though you have separate processes in Elixir a big write call will delay reading bytes from the OS's internal buffers. Based on your experiment, I would assume that the OS's internal buffer is 4096 bytes and when you write more than that, the OS drops the additional bytes. If the C code were actively removing bytes from the serial port while the big write was happening, this wouldn't happen. Interestingly enough, I had a note about this coupling in the C implementation, but I had thought that it only would affect performance and since serial ports generally only operate at very slow speeds, I didn't worry about it. This is an interesting consequence of running two UARTs and looping them back on each other that I hadn't considered. I hadn't run into this use case in my own work. This issue could certainly be fixed. It's a little tricky, though, and I don't have time at the moment to do it. I'm really glad that you pointed this out, since I bet others may run into it and it feels more legit now to spend time decoupling the read and write paths in the C code. |
Thank you very much for your detail answer. Is there one buffer per physical device? or one per device in Does that mean that if I run the process on two machines I will not have the problem? |
Hmm. Now I'm less sure. I was thinking that you were reading and writing to one device and the receive wire was connected to the transmit wire. If you have two Are you running on Linux? Also, have you tried removing the call to As for two machines, I would absolutely hope that you wouldn't see this problem on two machines. If you did, then that pretty squarely points to the transmit side having a limit of sending 4K at a time. I don't see how that could be |
I am running on Linux. Removing the call to |
I am transmitting a file over a serial line. I read the file like this with an Elixir task:
and read the file with another task:
I have created the file with
dd
:dd if=/dev/urandom of=./input.bin bs=1024 count=683
.When setting
buff_size
to 4098 there are errors when transmitting the file:whereas a value of 4000 or 2048, or 1000 works. The same byte is always the incorrectly transmitted.
Is there a bug somewhere in the library or am I doing something wrong?
The text was updated successfully, but these errors were encountered: