Distinguishing CDCInterface UART

Aperta
#1,041 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
embedded-iot

Direzione di ricerca

Inizia da micropython/usb/usb-device-cdc/usb/device/cdc.py, in particolare da CDCInterface.desc_cfg, e verifica come _Device.init passi configuration_str ai descrittori USB. Usa lsusb -v con uno o più dispositivi RP2040 per esaminare i descrittori delle interfacce generati; il lavoro è completato quando le interfacce REPL e metriche espongono informazioni distintive affidabili e l'utilizzo è documentato o dimostrato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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_str in _Device.init like so: core.get().init(uart, configuration_str="Pico Query", builtin_driver=True)
  • Modifying desc_cfg within CDCInterface to try and an entry to the strs variable and then set that as the iInterface value:
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.

Lingua principale
Python
Stelle
2.9k
Fork
1.1k
Merge medio
7g 6h
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di micropython/micropython-lib

Tutte le issue di micropython/micropython-lib

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.