PDA

View Full Version : Differenciating in udev rules a Teensy 2 from a Teensy 3?



ausserirdischegesund
01-30-2013, 10:36 AM
I want to hook up both a Teensy 2 and a Teensy 3 (doing different things) to a TP-Link MR3020 router's USB connector (running OpenWRT Linux and via a hub). Both will be used via ser2net over the network. But how do I ensure I get the right device at the right port?

Is there a way to ensure that my Teensy 2 always ends up as /dev/ttyACM0 and my Teensy 3 always ends up as /dev/ttyACM1?
Is there any way to make use of the different hardware (Teensy 2 vs 3) to get udev to react differently? Or will I have to change the serial number (though I rather would not, because I think it might be cumbersome while developing both devices at the same time to change it all the time)?

TIA
Ralph

PaulStoffregen
01-30-2013, 12:20 PM
The most reliable way would involve editing the VID/PID numbers in the USB code, and of course in your udev rules. The numbers are assigned by the kernel, but udev can automatically create symbolic links. I'm not an expert in the finer points of udev, but the common practice seems to be leaving the kernel's names as-is and creating a completely different symbolic link with a very descriptive name.

Once you change the vid/pid, the teensy_reboot program will not automatically find the device. If using Arduino, you'll need to manually press the pushbutton after verify or compile.

Dave X
12-16-2014, 05:01 AM
The most reliable way would involve editing the VID/PID numbers in the USB code, and of course in your udev rules. The numbers are assigned by the kernel, but udev can automatically create symbolic links. I'm not an expert in the finer points of udev, but the common practice seems to be leaving the kernel's names as-is and creating a completely different symbolic link with a very descriptive name.

Once you change the vid/pid, the teensy_reboot program will not automatically find the device. If using Arduino, you'll need to manually press the pushbutton after verify or compile.


If you change the last rule of 49-teensy.rules to read:



KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666" \
, SYMLINK+="cu.teensy.p$attr{idProduct} cu.teensy.s$attr{serial}"


you'll get '/dev/cu.teensy.p0483' and '/dev/cu.teensy.s23140' -like symlinks.

The vendorID, productID, and serial number are defined in the arduino/teensyduino code (as of 1.0.6)




.../hardware/teensy/cores/usb_serial/usb_private.c // for teensy STR_SERIAL_NUMBER, VENDOR_ID, PRODUCT_ID

.../hardware/teensy/cores/teensy3/usb_desc.c // for teensy3 VENDOR_ID, PRODUCT_ID and usb_init_serialnumber()



If you are using the code from https://www.pjrc.com/teensy/usb_serial.html these are set in usb_serial.c