Distinguishing CDCInterface UART
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- embedded-iot
Research direction
Start with micropython/usb/usb-device-cdc/usb/device/cdc.py, especially CDCInterface.desc_cfg, and review how _Device.init passes configuration_str into the USB descriptors. Use lsusb -v with one or more RP2040 devices to inspect the generated interface descriptors; done when the REPL and metrics interfaces expose reliable distinguishing information and the usage is documented or demonstrated.
Written by the indexing model from the issue text.
Description
The cdc.CDCInterface works great for my use case of having a single RP2040 host a REPL for active interaction as well as a metrics endpoint for me to be able to gather data from my device while interacting with it.
The issue I've run into is being able to programmatically distinguish between the two interfaces. Typically the REPL comes in as the lower /dev/ttyACM* number and the virtual serial port as the higher in the pair. With multiple RP2040's plugged into my PC though it becomes a lot of guess work to distinguish who is the metrics interface and who is the REPL per device.
I've tried a few things:
- Setting args like
configuration_strin_Device.initlike so:core.get().init(uart, configuration_str="Pico Query", builtin_driver=True) - Modifying
desc_cfgwithin CDCInterface to try and an entry to thestrsvariable and then set that as theiInterfacevalue:
def desc_cfg(self, desc, itf_num, ep_num, strs):
# ...
if "Pico Query" not in strs:
strs.append("Pico Query")
i_data = desc._get_str_index("Pico Query") # should now return nonzero
# Now add the data interface
desc.interface(
itf_num + 1,
_CDC_DATA_EP_NUM,
_CDC_ITF_DATA_CLASS,
_CDC_ITF_DATA_SUBCLASS,
_CDC_ITF_DATA_PROT,
iInterface=i_data
)
# ...
But I'm never able to see a distinguishing value in lsusb -v to tell the two interfaces apart.
I'm probably missing something -- I'd love to contribute an example if someone can point me in the right direction.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·