micropython / micropython/micropython-lib

usb-device-cdc raises TypeError when using default timeout of None and going to block

Open
#993 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 6h
Merged PRs (30d)
3

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with micropython/usb/usb-device-cdc/usb/device/cdc.py at the timeout check around line 368, then inspect the corresponding read function. Verify that the default timeout of None can block without raising TypeError, while finite timeouts still return when they expire.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.