Associate physical usb port to device

偶尔善良 提交于 2021-02-10 07:33:28

问题


I'm curently working on a testbench for some pcbs. They can be controlled though USB. I wrote some python code to send (using pySerial) orders to one card via the serial device "/dev/ttyACM0" The problem is that I need to test 5 cards at a time which means I need to differentiate which card is controlled with “/dev/ttyACM*” and * depends on the pluging order (which I don’t control).

I used “usb-devices” command to have the name of each physical usb port but I need to send orders to these via pySerial. Is there a way to make that work?

Another solution I found is to use the “Dev: n” number from “usb-devices” to communicate with “/dev/ttyn” but the permission to communicate through pySerial is denied, any idea?


回答1:


Look in directory /dev/serial/by-path/. You should find a link to each tty eg ../../dev/ttyACM0. The path should be stable. You can open these links just like /dev/ttyACM0.



来源:https://stackoverflow.com/questions/62779186/associate-physical-usb-port-to-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!