简体   繁体   English

断开时一致的USB端口编号

[英]Consistent USB Port numbering on disconnect

I have a project where I have several dozen cameras connected to my Ubuntu 12.04 laptop via USB and I need to grab images from these cameras via Gphoto2 我有一个项目,我有几十台摄像头通过USB连接到我的Ubuntu 12.04笔记本电脑,我需要通过Gphoto2从这些摄像头抓取图像

The problem is that when I disconnect the USB cable and re-connect it, the USB port number increments so I'm unable to tell which camera I am communicating with when grabbing images as gphoto requires me to define a port number from which to grab images. 问题是,当我断开USB电缆并重新连接时,USB端口号会递增,所以当抓取图像时我无法分辨我正在与哪个摄像头通信,因为gphoto要求我定义一个端口号从中抓取图片。

Is there any way of resetting the USB port numbers so that the USB Ports are assigned based on the sequence which they are plugged in? 有没有办法重置USB端口号,以便根据插入的顺序分配USB端口? Or is there any other method that I can use to map the cameras so that I can retrieve images from the correct camera every time? 或者我可以使用任何其他方法来映射相机,以便每次都能从正确的相机中检索图像?

You can probably use a combination of Vendor id and serial number to track down the exact camera or any other usb device. 您可以使用供应商ID和序列号的组合来跟踪确切的相机或任何其他USB设备。 Few devices such as USB flash drives do not have serial numbers (I haven't used a usb camera with linux so far). 很少有设备如USB闪存驱动器没有序列号(到目前为止我还没有使用带有linux的USB摄像头)。 You can explore (/sys/bus/usb/devices/../ and 'lsusb -v') for more info on this. 您可以浏览(/sys/bus/usb/devices/../和'lsusb -v')以获取更多信息。

This probably isn't the answer you're looking for, but I always use an external hub when order matters. 这可能不是您正在寻找的答案,但在订单问题时我总是使用外部集线器。 These tend to enumerate devices in a logical manner if they're all connected to the hub when the hub is attached to the PC. 如果设备在集线器连接到PC时全部连接到集线器,则这些设备倾向于以逻辑方式枚举设备。 You have to figure out the hub logic by running a few trials. 您必须通过运行一些试验来确定集线器逻辑。 On many that I've played with, the order has generally been from one side to another. 在我玩过的许多人中,订单通常是从一方到另一方。 For example, my CyberPower hub enumerates like the numbering of pins on an integrated circuit DIP from the upper left most port, counter-clockwise. 例如,我的Cyber​​Power集线器列举了从左上角端口逆时针方向的集成电路DIP上的引脚编号。 This means that when I attach six USB to serial devices and then connect the hub to the PC, they come up as /dev/ttyUSB0 - 5 in that same order. 这意味着当我将六个USB连接到串行设备然后将集线器连接到PC时,它们以相同的顺序出现为/ dev / ttyUSB0-5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM