-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Handle unexpected events on serial ports #8046
Conversation
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
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.
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
✅ Build completed.
Please test this code using one of the following:
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-791-linux32.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-791-linux64.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-791-windows.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-791-macosx.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-791-linuxarm.tar.xz
i️ The linuxarm
build is still experimental and may not be always available.
Similar to minicom behaviour. Automatically reopens the port only if it takes the same name (could be improved based on vid/pid)
d195cc4
to
d2f8e15
Compare
✅ Build completed.
Please test this code using one of the following:
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-884-linux32.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-884-linux64.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-884-windows.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-884-macosx.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-8046-BUILD-884-linuxarm.tar.xz
i️ The linuxarm
build is still experimental and may not be always available.
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.