mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-06-02 09:46:34 +03:00
Improve messaging
This commit is contained in:
@@ -101,7 +101,7 @@ struct dfu_dev *dfu_open(const char *port_spec) {
|
||||
*/
|
||||
|
||||
if(!str_starts(port_spec, "usb:") && !str_eq(port_spec, "usb")) {
|
||||
pmsg_error("port name %s must be usb:<bus>:<device>\n", port_spec);
|
||||
pmsg_error("invalid -P %s; drop this option or use -P usb:<bus>:<device>\n", port_spec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid) {
|
||||
*/
|
||||
|
||||
if(pid == 0 && dfu->dev_name == NULL) {
|
||||
pmsg_error("no DFU support for part; specify <pid> in config or USB address via -P usb:<bus>:<dev>\n");
|
||||
pmsg_error("no DFU support for part; specify <pid> in config or USB address via -P usb:<bus>:<device>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -585,6 +585,11 @@ static int micronucleus_open(PROGRAMMER *pgm, const char *port) {
|
||||
struct pdata *pdata = &my;
|
||||
const char *bus_name = NULL, *dev_name = NULL;
|
||||
|
||||
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
|
||||
pmsg_error("invalid -P %s; drop this option or use -P usb:<bus>:<device>\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Calculate bus and device names from -P usb:<bus>:<device> option if present
|
||||
if(str_starts(port, "usb:")) {
|
||||
bus_name = port + 4;
|
||||
@@ -683,7 +688,7 @@ static int micronucleus_open(PROGRAMMER *pgm, const char *port) {
|
||||
}
|
||||
|
||||
if(bus_name && !dev_name) { // Delayed error message, so found devices are printed with -P usb:xyz
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device>\n", port);
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device> or -P usb\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -580,7 +580,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
|
||||
#endif
|
||||
|
||||
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
|
||||
pmsg_error("port name %s must be usb:<vid>:<pid> or usb:<serno>\n", port);
|
||||
pmsg_error("invalid -P %s; use -P usb:<vid>:<pid>, -P usb:<serialno> or -P usb\n", port);
|
||||
return -1;
|
||||
}
|
||||
unsigned int new_vid = 0, new_pid = 0, setids = 0;
|
||||
@@ -612,7 +612,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
|
||||
if(vidp != pidp) { // User specified an VID
|
||||
// First: Handle VID input
|
||||
if(sscanf(vidp, "%x", &new_vid) != 1) {
|
||||
pmsg_error("failed to parse -P VID input %s: unexpected format\n", vidp);
|
||||
pmsg_error("failed to parse -P VID input %s: expected hexadecimal number\n", vidp);
|
||||
return -1;
|
||||
}
|
||||
} else { // VID space empty: default to Microchip
|
||||
@@ -621,7 +621,7 @@ static int pickit5_open(PROGRAMMER *pgm, const char *port) {
|
||||
|
||||
// Now handle PID input
|
||||
if(sscanf(pidp + 1, "%x", &new_pid) != 1) {
|
||||
pmsg_error("failed to parse -P PID input %s: unexpected format\n", pidp+1);
|
||||
pmsg_error("failed to parse -P PID input %s: expected hexadecimal number\n", pidp+1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
10
src/usbasp.c
10
src/usbasp.c
@@ -620,6 +620,11 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
||||
if(pgm->bitclock && !(pgm->extra_features & HAS_BITCLOCK_ADJ))
|
||||
pmsg_warning("setting bitclock despite HAS_BITCLOCK_ADJ missing in pgm->extra_features\n");
|
||||
|
||||
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device>, -P usb:<serialno> or -P usb\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// usb_init will be done in usbOpenDevice
|
||||
LNODEID usbpid = lfirst(pgm->usbpid);
|
||||
int pid, vid;
|
||||
@@ -649,11 +654,6 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
||||
*/
|
||||
}
|
||||
|
||||
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device> or -P usb:<serialno>\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pmsg_error("cannot find USB device with vid=0x%x pid=0x%x", vid, pid);
|
||||
if(pgm->usbvendor && *pgm->usbvendor)
|
||||
msg_error(" vendor='%s'", pgm->usbvendor);
|
||||
|
||||
@@ -287,6 +287,11 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *port) {
|
||||
|
||||
pmsg_debug("%s(\"%s\")\n", __func__, port);
|
||||
|
||||
if(!str_starts(port, "usb:") && !str_eq(port, "usb")) {
|
||||
pmsg_error("invalid -P %s; drop this option or use -P usb:<bus>:<device>\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Calculate bus and device names from -P usb:<bus>:<device> option if present
|
||||
if(str_starts(port, "usb:")) {
|
||||
bus_name = port + 4;
|
||||
@@ -338,7 +343,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *port) {
|
||||
}
|
||||
|
||||
if(bus_name && !dev_name) { // Delayed error message, so found devices are printed with -P usb:xyz
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device>\n", port);
|
||||
pmsg_error("invalid -P %s; use -P usb:<bus>:<device> or -P usb\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user