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

Intermittent failure to set tuner output level (*OF2) due to Serial race condition #5

Open
cjritola opened this issue Jun 26, 2021 · 0 comments

Comments

@cjritola
Copy link
Contributor

In hardware_usbserial.py, the delay given by Python/Linux between opening a port and when it is available for writing is undefined. The current convention is to use delays, such as in the original source, as well as for other projects:
https://stackoverflow.com/questions/7266558/pyserial-buffer-wont-flush

... however, this still didn't work on my system, the *OF2 setting was not parsed by the RS-HFIQ except for rare situations by chance. Setting the delay longer improved the probability but doesn't really fix the underlying problem.

There appears to be a design flaw in Python or the way Linux interacts with serial where a handshake interaction may help things, such as getting the firmware version *W to confirm that the device is communicating before issuing state commands like *OF2, which don't have a confirmation back.

The odd thing is, strace shows the messages actually being sent out to serial at the OS level:

38110 ioctl(10, TCFLSH, TCIFLUSH)       = 0
38110 ioctl(10, TCFLSH, TCIFLUSH)       = 0
38110 ioctl(10, TCFLSH, TCOFLUSH)       = 0
38110 write(10, "*OF2\r", 5)            = 5
38110 select(14, [13], [10], [], NULL)  = 1 (out [10])
38110 ioctl(10, TCFLSH, TCOFLUSH)       = 0
38110 ioctl(10, TCFLSH, TCIFLUSH)       = 0
38110 ioctl(10, TCFLSH, TCOFLUSH)       = 0
38110 write(10, "*W\r", 3)              = 3

... perhaps write() doesn't truly wait for the message to be sent. Consequently when flushOutput is invoked, the message is removed from the queue?

Will be submitting a pull request for an improvement soon.

dl1ksv added a commit that referenced this issue Jun 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Fixes for issues #5 and #6
As I never notice #5 , I can't test if  your fix solves the described problem, but your fix looks reasonable.
I can reproduce #6 and your pr fixes this issue.
Thanks.
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