I have 3 USB webcams and 3 Arduino's plugged into the same computer. On startup, they are labeled /dev/videoN
(N goes from 0 to 2) and /dev/ttyACMN
(N goes from 0 to 2). So far, so good.
The problem is when something goes wrong with one of the devices (ie, the Arduino, its IDE, or the video capture program crashes). Then the device is assigned a new device file (like /dev/video3
or /dev/ttyACM3
). I would like to keep the same device file instead.
Plugging and unplugging the device does not help; neither does closing all the programs that should be interacting with it. If the problem occurs a second time, then yet another device file is created with an even higher number.
It's as if a handle to the old device file is floating around somewhere, and preventing the same device file from being reused. However, the original device file itself (say, /dev/ttyACM0
) no longer exists, or at least does not show up in a directory listing.
The only way I have figured out to fix this problem is to reboot. Instead of rebooting, is there a way to purge any lingering references to the original device file so that it can be reused? Or, to force a total purge of all USB devices and renumber from scratch?