Skip to content

Handle unexpected events on serial ports #8046

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

Merged
merged 4 commits into from
Jul 18, 2019

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Oct 1, 2018

While working with low power, the serial port can disappear/reappear very often (see arduino-libraries/ArduinoLowPower#7).

This makes using the serial monitor very frustrating (especially on Linux) since the port will acquire another name if reconnected while the monitor is open. Changing port will close the monitor for good, so it must be reopened manually.

This patch tries to add a couple of "helpers" to make the situation less terrible.

  • Automatically reopens the serial monitor when changing port.
  • Suspend the serial monitor when the board disappears, and try resuming when it reappears.

@grezco
Copy link

grezco commented Oct 1, 2018

I tried this IDE version, but with MKR WiFi1010, on Windows 10, it's the same problem.
The serial.print is not working anymore after it is waking up

@PaulStoffregen
Copy link
Contributor

Could this be done without the timer?

If you look at the work on PluggableDiscovery and try running SerialDiscovery_JSON on Linux, the future may look like near real-time response to USB add & remove events.

One second delay isn't very long for humans, but a device can reset and reappear withing 1 second on most Linux & Mac systems. Even Windows 10 is better about delays with detecting devices. And that's just USB.

@facchinm
Copy link
Member Author

facchinm commented Oct 2, 2018

1 second delay is just an example; we could be much more tight since calling discovery() does only recover the cached port list (which are polled once per second or by the event in your implementation).
Anyway, I'm still waiting for libusb/libusb#86 to be finished so we can have a cross platform way to perform hotplug detection

@facchinm facchinm added this to the Release 1.8.8 milestone Oct 5, 2018
@facchinm facchinm force-pushed the serial_monitor_reopen_change branch from d195cc4 to d2f8e15 Compare July 8, 2019 10:08
@per1234
Copy link
Collaborator

per1234 commented Jul 11, 2019

@facchinm build 884 fixes the upload failure reported in #8851 for me. I still get the double ports entry reported there, but I think that part of the issue is already fixed by a different commit since it doesn't occur in the beta build of the IDE, so that's no problem. Thanks!

@facchinm facchinm merged commit ef8d669 into arduino:master Jul 18, 2019
@facchinm facchinm deleted the serial_monitor_reopen_change branch July 18, 2019 08:11
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

Successfully merging this pull request may close these issues.

5 participants