将物理 USB 端口关联到设备 [英] Associate physical usb port to device

查看:70
本文介绍了将物理 USB 端口关联到设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为一些 pcb 开发测试平台.它们可以通过 USB 进行控制.我编写了一些 python 代码,通过串行设备/dev/ttyACM0"将(使用 pySerial)订单发送到一张卡.问题是我需要一次测试 5 张卡,这意味着我需要区分哪张卡是用/dev/ttyACM*"控制的,*取决于插入顺序(我不控制).

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).

我使用usb-devices"命令来获取每个物理 USB 端口的名称,但我需要通过 pySerial 向这些端口发送命令.有没有办法让它发挥作用?

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?

我发现的另一个解决方案是使用usb-devices"中的Dev:n"号与/dev/ttyn"通信,但通过 pySerial 通信的权限被拒绝,知道吗?

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?

推荐答案

在目录 /dev/serial/by-path/ 中查找.您应该找到每个 tty 的链接,例如 ../../dev/ttyACM0.路径应该是稳定的.您可以像 /dev/ttyACM0 一样打开这些链接.

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.

这篇关于将物理 USB 端口关联到设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆