From 88035867c5549ee42484edfdde95322a8fbc9188 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Sun, 15 Feb 2026 13:40:14 +1100 Subject: [PATCH] usb-device-cdc: Fix default timeout in CDCInterface.init(). CDCInterface.__init__() sets self._timeout = 1000, then calls self.init(**kwargs). The init() method had timeout=None as default, which unconditionally overwrites self._timeout with None. This causes TypeError in read(), write(), readinto(), and ioctl() which all compare int >= self._timeout. Set the default timeout=1000 in init() to match the intended default, consistent with how other parameters (baudrate, bits, etc.) have their defaults specified directly in the init() signature. Signed-off-by: Andrew Leech --- micropython/usb/usb-device-cdc/usb/device/cdc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/usb/usb-device-cdc/usb/device/cdc.py b/micropython/usb/usb-device-cdc/usb/device/cdc.py index 4ec012bc5..a51941bc0 100644 --- a/micropython/usb/usb-device-cdc/usb/device/cdc.py +++ b/micropython/usb/usb-device-cdc/usb/device/cdc.py @@ -122,7 +122,7 @@ def __init__(self, **kwargs): self.init(**kwargs) def init( - self, baudrate=9600, bits=8, parity="N", stop=1, timeout=None, txbuf=256, rxbuf=256, flow=0 + self, baudrate=9600, bits=8, parity="N", stop=1, timeout=1000, txbuf=256, rxbuf=256, flow=0 ): # Configure the CDC serial port. Note that many of these settings like # baudrate, bits, parity, stop don't change the USB-CDC device behavior