mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-28 12:06:59 +03:00
Utilise str_set_vid_pid_serno() for teensy.c
This commit is contained in:
@@ -612,9 +612,8 @@ USB-only programmers normally do not need the port option be specified as
|
||||
they are automatically identified via their vendor and product IDs from
|
||||
avrdude.conf or .avrduderc. Only when there are multiple programmers of
|
||||
the same type plugged into the host computer is the -P option needed, see
|
||||
below. Some -c programmers, however, ignore the -P option altogether, eg,
|
||||
pickit2 or teensy; these cannot distinguish multiple plugged-in
|
||||
programmers.
|
||||
below. Some -c programmers, eg, pickit2, ignore the -P option altogether;
|
||||
these cannot distinguish multiple plugged-in programmers.
|
||||
.Pp
|
||||
Most USB programmers, however, support the command-line syntax -P
|
||||
usb[:<vid>:<pid>][:<serialno>] which allows the user to override the
|
||||
@@ -623,9 +622,9 @@ request a match of the desired device's serial number with <serialno>. The
|
||||
match is done after stripping any existing colons from the given serial
|
||||
number on the command line, and right-to-left, so only the least
|
||||
significant bytes from the serial number need to be given. The JTAG ICE
|
||||
mkII, JTAGICE3, SNAP, PICKit5, CH341A and avrftdi programmers are examples
|
||||
for this -P port syntax. Some of these in turn, e.g. the CH341A, are not
|
||||
capable of matching serial numbers.
|
||||
mkII, JTAGICE3, SNAP, PICKit5, CH341A, teensy and avrftdi programmers are
|
||||
examples for this -P port syntax. Some of these in turn, e.g. the CH341A
|
||||
and teensy are not capable of matching serial numbers.
|
||||
.Pp
|
||||
If
|
||||
.Nm
|
||||
|
||||
@@ -839,9 +839,9 @@ USB-only programmers normally do not need the port option be specified as
|
||||
they are automatically identified via their vendor and product IDs from
|
||||
@code{avrdude.conf} or @code{.avrduderc}. Only when there are multiple
|
||||
programmers of the same type plugged into the host computer is the
|
||||
@code{-P} option needed, see below. Some @code{-c} programmers, however,
|
||||
ignore the @code{-P} option altogether, eg, pickit5 or teensy;
|
||||
these cannot distinguish multiple plugged-in programmers.
|
||||
@code{-P} option needed, see below. Some @code{-c} programmers, e.g.,
|
||||
pickit5, ignore the @code{-P} option altogether; these cannot distinguish
|
||||
multiple plugged-in programmers.
|
||||
|
||||
Most USB programmers, however, support the command-line syntax @code{-P
|
||||
usb[:@var{vid}:@var{pid}][:@var{serialno}]} which allows the user to
|
||||
@@ -850,9 +850,10 @@ override the vendor and product IDs with hexadecimal numbers @var{vid} and
|
||||
with @var{serialno}. The match is done after stripping any existing colons
|
||||
from the given serial number on the command line, and right-to-left, so
|
||||
only the least significant bytes from the serial number need to be given.
|
||||
The JTAG ICE mkII, JTAGICE3, SNAP, PICKit5, CH341A and avrftdi programmers
|
||||
are examples for this @code{-P} port syntax. Some of these in turn, e.g.
|
||||
the CH341A, are not capable of matching serial numbers.
|
||||
The JTAG ICE mkII, JTAGICE3, SNAP, PICKit5, CH341A, teensy and avrftdi
|
||||
programmers are examples for this @code{-P} port syntax. Some of these in
|
||||
turn, e.g. the CH341A and teensy, are not capable of matching serial
|
||||
numbers.
|
||||
|
||||
If avrdude has been configured with libserialport support, a serial port
|
||||
can be specified using a predefined serial adapter type in
|
||||
|
||||
34
src/teensy.c
34
src/teensy.c
@@ -305,28 +305,32 @@ static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
}
|
||||
|
||||
static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
||||
char serno[64] = {0};
|
||||
unsigned short new_vid = 0, new_pid = 0;
|
||||
int vid, pid, numids;
|
||||
|
||||
pmsg_debug("%s(\"%s\")\n", __func__, port);
|
||||
if(!str_caseeq(port, "usb"))
|
||||
pmsg_warning("option -P %s ignored\n", port);
|
||||
|
||||
// Set new_vid, new_pid and/or serno from -P usb[:<vid>:<pid>]
|
||||
if((numids = str_set_vid_pid_serno(port, &new_vid, &new_pid, serno, sizeof serno)) < 0) {
|
||||
pmsg_error("invalid -P %s; drop -P option or use -P usb[:<vid>:<pid>]\n", port);
|
||||
return LIBAVRDUDE_EXIT_FAIL;
|
||||
}
|
||||
if(*serno)
|
||||
pmsg_warning("ignoring serial number %s given in -P %s\n", serno, port);
|
||||
|
||||
// Set vid/pid in following priority: command-line, config, default
|
||||
vid = numids >= 2? new_vid: pgm->usbvid? pgm->usbvid: TEENSY_VID;
|
||||
LNODEID usbpid = lfirst(pgm->usbpid);
|
||||
pid = numids >= 2? new_pid: usbpid? *(int *) ldata(usbpid): TEENSY_PID;
|
||||
if(numids < 2 && usbpid && lnext(usbpid))
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
|
||||
if(pgm->bitclock)
|
||||
pmsg_warning("-c %s does not support adjustable bitclock speed; ignoring -B\n", pgmid);
|
||||
|
||||
struct pdata *pdata = &my;
|
||||
|
||||
// Determine VID/PID
|
||||
int vid = pgm->usbvid? pgm->usbvid: TEENSY_VID;
|
||||
int pid = TEENSY_PID;
|
||||
|
||||
LNODEID usbpid = lfirst(pgm->usbpid);
|
||||
|
||||
if(usbpid != NULL) {
|
||||
pid = *(int *) ldata(usbpid);
|
||||
if(lnext(usbpid)) {
|
||||
pmsg_error("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
}
|
||||
}
|
||||
|
||||
bool show_retry_message = true;
|
||||
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
Reference in New Issue
Block a user