-
Notifications
You must be signed in to change notification settings - Fork 250
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
movement doesn't buffer serial input correctly #117
Comments
Just looked at the code in watch_private.c. There may be a few other issues:
|
test script import serial
ser = serial.Serial("/dev/ttyACM1",baudrate = 19200, timeout=1)
if ser.isOpen():
ser.write("echo otpauth://totp/ACME%20Co:[email protected]?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30 > totp_uris.txt".encode())
print(ser.read(256).decode("ascii"))
ser.write("ls".encode())
print(ser.read(256).decode("ascii"))
ser.write("cat totp_uris.txt".encode())
print(ser.read(256).decode("ascii"))
ser.close() and output is (two empty lines after
after replug
and
|
👍 nice test script. |
@josecastillo sorry disturbing you is it possible for you to take a look into the issue? It will be real quality of life improvement, it really will help us simplify firmware upgrade proces and keep sensitive data out of generic code. |
See #344 |
I believe this is now fixed following the merge of #344 and can be closed. |
movement.c uses
read
to grab something from the input, then processes it immediately, regardless of whether there's a newline in the buffer.This means that if you use a normal terminal emulator (i.e. picocom), which sends characters immediately as they're typed - as opposed to Arduino's one, which sends a bunch of characters at once - every filesystem_process_command is called with a single character. And even using Arduino's, you can only send about 50 chars or so before the line is effectively broken at that point due to how fast the characters are transmitted (or some buffer size somewhere).
I believe the easiest fix is to implement an fgets-ish thing in the loop. Unfortunately, we can't use normal fgets at the moment (AFAIK), as it will block up the loop. Moreover, even if we were prepared to be a bit hacky by calling fgets only once there was input to read, AFAIK because select/poll isn't implemented there's no way to detect if there's something is there without actually calling read(), and one is not supposed to mix read() with the normal stdio functions.
Note that from messing around with serial I/O I suspect there are also underlying issues with the serial implementation in TinyUSB, but this is the issue I'm 99% certain exists and is easily fixable.
The text was updated successfully, but these errors were encountered: