-
Notifications
You must be signed in to change notification settings - Fork 373
fix serial port open #2476
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
fix serial port open #2476
Conversation
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
|
Thanks for this. I reworked the serial port handling some here too: https://github.com/iNavFlight/inav-configurator/pull/2433/changes |
|
To really do it right, we might want to also add serialport.on('error' along with serialport.on('open': That way we don't have an unresolved promise hanging around. |
|
there is error handling, inav-configurator/js/main/serial.js Line 16 in db9a6a1
|
Good catch, there IS an error handler. It just leaves the promise unresolved and the then() not firing. Or to be defensive about it to make sure we never try to double-resolve. |
|
/ask qodo, do you have comments on the above discussion? |
Ask❓qodo, do you have comments on the above discussion? Answer:Yes — the change to resolve only after the "open" event is a good direction, but a couple of details are worth tightening up for robustness and consistency:
Example adjustment:
Net: The core idea (resolve on "open") fixes the race that caused early writes and timeouts. Adding an "error" path and cleanup will make it production-safe across platforms/drivers. |
|
I've found qodo is right about half the time, so the comments from the bot shouldn't be accepted at face value, but are things to consider. |
|
I amend your suggestion it meakes sense. I'm not fun of remove listeners, it makes code more dificult to read. |
fix serial port open
dbe9c07 to
751eb04
Compare
This PR needs review by someone who knows JS well.
I noticed that opening serial port is slow. The reasson is that serial port is not opened and configurator tries to write data serial port. It causes restart MSP quering and delay for opening configurator.
The flow is:
I would say it's caused by calling resolve before port is fully opened, right aproach call resolve when port is fully opened. See pull request code.
After my patch is connection to FC much faster and log look more clean