-
Notifications
You must be signed in to change notification settings - Fork 174
Description
Now that #1498 is pretty much complete and hopefully ready to be merged soon, the next step involving libserialport would be to finally support devices that require a serial port "touch" before communication can be established.
To perform "touch" (usually 1200 baud) is as simple as opening the serial port, and waiting a little, just to make sure that the decide in the other end has enough time to jump into "bootloader mode" and close it again.
Some boards, like the Arduino Leonardo or the Arduino Micro, will re-appear with a different USB VID/PID, which may on some OSes result in a new /dev path or COM port number. other boards, like the Arduino Nano Every will not appear as a new device.
Here's how I imagine it can be done if we add a new command line flag that specifies the "touch" baud rate, for instance -r 1200 (please suggest a better-suited flag if you have one. -r just happens to be available).
- The user tries to connect to a serial port and has specified -r, for instance:
avrdude -c avr109 -p atmega32u4 -P usb:2341:0058 -b 57600 -r 1200
- Before opening any serial ports, Avrdude creates a list of all available serial ports using libserialport, that contains, their path, USB VID, USB PID, and USB SN.
- If -r is specified, Avrdude opens the serial port (specified using -P) with the baud rate specified by -r.
- Avrdude waits a little, closes the port, and waits a little more.
- Avrdude creates a new list of the available serial ports.
- If a new port has appeared (when compared to the list created earlier), connect to this port using the default baud rate (115200) or the user-specified one (-b). If there are no changes, connect to the previously used port
I doubt this would be very difficult to implement, now that #1498 contains some of the boilerplate code needed to implement this feature.
Any thoughts or ideas?