autodetecting arduino on linux?

Well I just found than the Uno needs avrdude option '-P /dev/ttyACM0', while the old Duemilanove needed '-P /dev/ttyUSB0'. At least that's how it ends up being on debian.

I have some software I wrote ( and it tries to spare the user some of these details or at least help out with them. So I'm wondering if there is a reliable way to detect when an arduino is plugged into USB from the linux side.

Right now I just test for the existence of the above device files, and take a look at the lsusb output. The lsusb output contains a line like this when a Uno is plugged in:

Bus 003 Device 003: ID 2341:0043

So I wonder if the vendor ID (2341) and/or product ID (0043) are standard for all Uno arduinos, or not?

For the Duemilanove, we get a line like this:

Bus 003 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

but this looks like the FTDI chip that the older Duemilanove used, and might be used in other devices (i.e. the vendor and device ID are almost certainly not truly arduino-specific, though they probably mostly work).

Finally, it occurs to me that if other USB devices are in use, then /dev/ttyACM0 or /dev/ttyUSB0 might be the wrong guesses for the device name. So what I'd like to do is this:

  1. Probe USB using lsusb to find the arduino.
  2. Using the results of 1., fidn the device name (e.g. /dev/ttyACM0).

Step 1 I can sort of do as described above, but I don't know how generic my approach is. I don't know how to do step 2, does anyone know a way to determine the device starting from the USB info.

Any help or advice how to proceed would be greatly appreciated.


Did you ever figure this out?