Finally, this method works much better at low baud rate than at high baud rate, which for timing reasons may not succeed every time. They all must use the same baud rate as the script unless you want to write a very complex script that takes a long time. All of your cheapduinos must have this functionality in their software, with different device IDs set. Also this is not using the SYMLINK function of udev so it won't clean up dead links on disconnect, but it will overwrite them on reconnect.
The script must time out if the software on the cheapduino doesn't answer. There are a lot of drawbacks to this method. The script then creates a symlink /dev/THX1138 that points to /dev/ttyUSB0
Then the cheapduino script connects by serial to the device and sends the string 'ID' and the software on the device responds DEVID=THX1138 or whatever. When the device matches the product and vendor of the cheap arduino, it runs the script 'cheapduino.py' with the device as argument, for instance
I created a udev rule that looks like this:
This one-hub trick should work for MacOS and windows too, they should come up in the same order.įor devices with a unique ID such as FTDI you can set a udev rule that sees it's serial number and then creates a symlink to that device, it's straightforward.įor devices with the same or no Serial number, it's a lot more complex. The devices will enumerate in the order that they are plugged in to the hub. If you have a lot of changes to your USB devices, plug all the CH340 devices into the same hub, then plug that in. This position, and the device names, should persist across reboots. Cheap chips won't, but they each have an entry under /dev/serial/by-path. FTDI chips will each have unique entries here. There is also a /dev/serial/by-id but there will only be one entry there for this device because it shows the last one connected. If you're using linux you can find each device under /dev/serial/by-path. First and easiest is the position of the device on the USB bus. I have been trying to find solutions for this problem.
This is also a problem for the PL2303 type. There is no storage on the CH340 and family of UARTs where you could put a unique ID. Which is essentially useless, as I can't identify the given board attached (when I attach two, their details are the same). usb 2-1.2: ch341-uart converter now attached to ttyUSB0 usb 2-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0 usb 2-1.2: New USB device found, idVendor=1a86, idProduct=7523 Does anyone know of an alternative utility/where I can find information to do the same with this chip?Ĭurrently the device identifies itself with: usb 2-1.2: new full-speed USB device number 7 using ehci-pci I have a nano-style boad with a QinHeng Electronics HL-340 USB-Serial adapter, which clearly isn't an FTDI chip, and the FTDI programmer therefore doesn't work. Reading there appears to be a way to write out to a FTDI USB-Serial EEPROM to set a given SerialNumber, allowing you to identify a given nano/other arduino to handle it specifically in UDEV.