summaryrefslogtreecommitdiff
path: root/shared-bindings/supervisor
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-09-03 13:36:15 -0500
committerJeff Epler <jepler@gmail.com>2020-09-17 18:32:06 -0500
commit28043c94b5ea5f3cce11fa57afa9f3f0141b8dce (patch)
tree5754029d2c5dfda23066264fba16942db4eb1809 /shared-bindings/supervisor
parent7f60ebd6c76841b338a4566c28c7cbfe28bee797 (diff)
supervisor: Improve serial connection detection
These changes remove the caveat from supervisor.runtime.serial_connected. It appears that _tud_cdc_connected() only tracks explicit changes to the "DTR" bit, which leads to disconnects not being registered. Instead: * when line state is changed explicitly, track the dtr value in _serial_connected * when the USB bus is suspended, set _serial_connected to False Testing performed (using sam e54 xplained): Run a program to show the state of `serial_connected` on the LED: ``` import digitalio import supervisor import board led = digitalio.DigitalInOut(board.LED) while True: led.switch_to_output(not supervisor.runtime.serial_connected) ``` Try all the following: * open, close serial terminal program - LED status tracks whether terminal is open * turn on/off data lines using the switchable charge-only cable - LED turns off when switch is in "charger" position - LED turns back on when switch is in Data position and terminal is opened (but doesn't turn back on just because switch position is changed)
Diffstat (limited to 'shared-bindings/supervisor')
-rwxr-xr-xshared-bindings/supervisor/Runtime.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c
index 84d8370dd..bfca6e7b1 100755
--- a/shared-bindings/supervisor/Runtime.c
+++ b/shared-bindings/supervisor/Runtime.c
@@ -46,13 +46,7 @@
//|
//| serial_connected: bool
-//| """Returns the USB serial communication status (read-only).
-//|
-//| .. note::
-//|
-//| SAMD: Will return ``True`` if the USB serial connection
-//| has been established at any point. Will not reset if
-//| USB is disconnected but power remains (e.g. battery connected)"""
+//| """Returns the USB serial communication status (read-only)."""
//|
STATIC mp_obj_t supervisor_get_serial_connected(mp_obj_t self){