Open hmaarrfk opened 4 years ago
Hi @hmaarrfk, I also want to write to multiple teensy (same version, 3 teensy 4.1s). When it open Teensy, it specify vid and pid. https://github.com/PaulStoffregen/teensy_loader_cli/blob/master/teensy_loader_cli.c#L669 Teensy have same vid and pid. I think that new function option need to specify usb port.
You can try
https://github.com/PaulStoffregen/teensy_loader_cli/pull/57
Only works on linux.
I did the bad thing on releasing the feature on conda forge as well
Thank you. That's helpful for me!! I will try it.
Greetings, I was playing around with your changes so I can use this serial-number functionality with PlatformIO to flash my two teensy via USB only and I noticed a strange thing.
This is the output from usb-devices for my teensy:
T: Bus=03 Lev=02 Prnt=05 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=16c0 ProdID=0486 Rev=02.79
S: Manufacturer=Teensyduino
S: Product=Teensyduino RawHID
S: SerialNumber=7365140
C: #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
As you see, my serial-number is 7365140.
I had issues flashing my teensy and noticed that the serial-number which gets parsed out of your code is not matching to my serial-number.
I added some prints to your code:
...
if (dev->descriptor.iSerialNumber) {
// langid 0x0409 is English US
r = usb_get_string(h, dev->descriptor.iSerialNumber, 0x0409, buf, 128);
if (r < 0) {
usb_close(h);
continue;
}
// Seemsl like 16 bit wide chars are being sent
for (i=0; i < r/2; i++){
buf[i] = buf[i * 2];
}
printf("%s\n", buf);
// The first char seems to be of value 16
// meaning DATA LINK ESCAPE. Who knows what that means???
read_serial_number = &buf[1];
printf("%s\n", read_serial_number);
} else {
...
Here is the output of PlatformIO using your changes + outputs from me:
...
Configuring upload protocol...
AVAILABLE: custom, jlink, teensy-gui
CURRENT: upload_protocol = custom
Uploading .pio/build/teensy_rear/firmware.hex
Teensy Loader, Command Line, Version 2.2
Read ".pio/build/teensy_rear/firmware.hex": 16180 bytes, 0.8% usage
73651405
73651405
Sending reboot command to 7365140
...
Any idea why this happens? Either usb-devices is not displaying the serial numbers correctly or the conversion from 16bit values to 8bit is not working right.
do you have two teensies connected?
In the run shown above, no.
are you using a standard intel based computer? I've been using this for quite some time and it seems to be "working" but maybe there is a bug....
For use cases where we have multiple teensies connected, is it possible to specify which one we program via their serial number? usb port?