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

Serial read not working correctly on Linux #16

Open
NomAnor opened this issue Dec 24, 2023 · 0 comments
Open

Serial read not working correctly on Linux #16

NomAnor opened this issue Dec 24, 2023 · 0 comments

Comments

@NomAnor
Copy link

NomAnor commented Dec 24, 2023

I'm trying the program on Arch Linux and it seems the Linux COM_Read read function is not working correctly. From debugging it with strace, I could see that the read() call only returns one byte instead of three and the remaining spill over to the next write/read pair.

write(1, "INFO: STCS to 0x03\n", 19INFO: STCS to 0x03
)    = 19
write(3, "U\303\10", 3)                 = 3
read(3, "U", 3)                         = 1
write(1, "INFO: STCS to 0x02\n", 19INFO: STCS to 0x02
)    = 19
write(3, "U\302\200", 3)                = 3
read(3, "\303", 3)                      = 1
write(1, "INFO: LDCS from 0x00\n", 21INFO: LDCS from 0x00
)  = 21
write(3, "U\200", 2)                    = 2
read(3, "\10", 2)                       = 1
read(3, "U", 1)                         = 1
write(1, "INFO: UPDI init OK\n", 19INFO: UPDI init OK
)    = 19

read() can return less than the given length of bytes, so the read call must be run in a loop until the expected bytes are received or an error occurs or the timeout expires.

I'm still testing but if I get everything working, I will try to create a pull request.

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

1 participant