usb-device-cdc raises TypeError when using default timeout of None and going to block
https://github.com/micropython/micropython-lib/blob/master/micropython/usb/usb-device-cdc/usb/device/cdc.py#L368
and same for read function.
# check for timeout
if time.ticks_diff(time.ticks_ms(), start) >= self._timeout:
return len(buf) - len(mv)
machine.idle()
should be something like this:
if isinstance(self._timeout, int) and time.ticks_diff(time.ticks_ms(), start) >= self._timeout:
usb-device-cdc: Fix default timeout in CDCInterface.init().
Summary
CDCInterface is broken when constructed with default arguments — calling read(), write(), readinto(), or flush() raises TypeError: unsupported types for __ge__: 'int', 'NoneType' because self._timeout ends up as None.
__init__ sets self._timeout = 1000 then immediately calls self.init(**kwargs). The init() method has timeout=None as default and unconditionally assigns self._timeout = timeout, overwriting the 1000 with None. All the stream methods then fail on time.ticks_diff(...) >= self._timeout.
Fix is changing the default parameter from timeout=None to timeout=1000, consistent with how the other init parameters (baudrate, bits, parity, stop) all carry their real defaults in the signature.
Testing
Tested on ESP32-S3 as USB CDC device with an MIMXRT1170-EVK as USB host. Confirmed cdc._timeout is now 1000 after default construction and read(), write(), readinto() all work without error. Also verified explicit timeout= parameter still takes effect.