bug #42662 clang warnings under FreeBSD 10.x
* avrftdi.c: remove warnings * buspirate.c: (Dito.) * dfu.c: (Dito.) * fileio.c: (Dito.) * libavrdude.h: (Dito.) * pickit2.c: (Dito.) * safemode.c: (Dito.) * ser_avrdoper.c: (Dito.) * ser_posix.c: (Dito.) * ser_win32.c: (Dito.) * stk500v2.c: (Dito.) * usb_libusb.c: (Dito.) * usbasp.c: (Dito.) * config_gram.y: fix problem when using parent part with usbpid lists (existing list was extended not overwritten) git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1328 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
8a387a198f
commit
8fd3870861
26
ChangeLog
26
ChangeLog
|
@ -1,7 +1,27 @@
|
||||||
|
2014-07-16 Rene Liebscher <R.Liebscher@gmx.de>
|
||||||
|
|
||||||
|
bug #42662 clang warnings under FreeBSD 10.x
|
||||||
|
* avrftdi.c: remove warnings
|
||||||
|
* buspirate.c: (Dito.)
|
||||||
|
* dfu.c: (Dito.)
|
||||||
|
* fileio.c: (Dito.)
|
||||||
|
* libavrdude.h: (Dito.)
|
||||||
|
* pickit2.c: (Dito.)
|
||||||
|
* safemode.c: (Dito.)
|
||||||
|
* ser_avrdoper.c: (Dito.)
|
||||||
|
* ser_posix.c: (Dito.)
|
||||||
|
* ser_win32.c: (Dito.)
|
||||||
|
* stk500v2.c: (Dito.)
|
||||||
|
* usb_libusb.c: (Dito.)
|
||||||
|
* usbasp.c: (Dito.)
|
||||||
|
|
||||||
|
* config_gram.y: fix problem when using parent part with usbpid lists
|
||||||
|
(existing list was extended not overwritten)
|
||||||
|
|
||||||
2014-07-11 Axel Wachtler <axel@uracoli.de>
|
2014-07-11 Axel Wachtler <axel@uracoli.de>
|
||||||
|
|
||||||
* avrftdi.c: rollback to vfprintf, fixed error from -r1305, (patch #8463)
|
* avrftdi.c: rollback to vfprintf, fixed error from -r1305, (patch #8463)
|
||||||
|
|
||||||
2014-06-23 Rene Liebscher <R.Liebscher@gmx.de>
|
2014-06-23 Rene Liebscher <R.Liebscher@gmx.de>
|
||||||
|
|
||||||
* linux_ppdev.h: added missing msg level for avrdude_message
|
* linux_ppdev.h: added missing msg level for avrdude_message
|
||||||
|
|
|
@ -190,7 +190,7 @@ static void buf_dump(const unsigned char *buf, int len, char *desc,
|
||||||
*/
|
*/
|
||||||
static int set_frequency(avrftdi_t* ftdi, uint32_t freq)
|
static int set_frequency(avrftdi_t* ftdi, uint32_t freq)
|
||||||
{
|
{
|
||||||
uint32_t divisor;
|
int32_t divisor;
|
||||||
uint8_t buf[3];
|
uint8_t buf[3];
|
||||||
|
|
||||||
/* divisor on 6000000 / freq - 1 */
|
/* divisor on 6000000 / freq - 1 */
|
||||||
|
@ -436,7 +436,7 @@ static int avrftdi_transmit_mpsse(avrftdi_t* pdata, unsigned char mode, const un
|
||||||
{
|
{
|
||||||
size_t transfer_size = (remaining > blocksize) ? blocksize : remaining;
|
size_t transfer_size = (remaining > blocksize) ? blocksize : remaining;
|
||||||
|
|
||||||
E(ftdi_write_data(pdata->ftdic, &buf[written], transfer_size) != transfer_size, pdata->ftdic);
|
E(ftdi_write_data(pdata->ftdic, (unsigned char*)&buf[written], transfer_size) != transfer_size, pdata->ftdic);
|
||||||
#if 0
|
#if 0
|
||||||
if(remaining < blocksize)
|
if(remaining < blocksize)
|
||||||
E(ftdi_write_data(pdata->ftdic, &si, sizeof(si)) != sizeof(si), pdata->ftdic);
|
E(ftdi_write_data(pdata->ftdic, &si, sizeof(si)) != sizeof(si), pdata->ftdic);
|
||||||
|
|
143
buspirate.c
143
buspirate.c
|
@ -91,59 +91,56 @@ buspirate_uses_ascii(struct programmer_t *pgm)
|
||||||
|
|
||||||
/* ====== Serial talker functions - binmode ====== */
|
/* ====== Serial talker functions - binmode ====== */
|
||||||
|
|
||||||
static void dump_mem(char *buf, size_t len)
|
static void dump_mem(const int msglvl, const unsigned char *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i<len; i++) {
|
for (i = 0; i<len; i++) {
|
||||||
if (i % 8 == 0)
|
if (i % 8 == 0)
|
||||||
avrdude_message(MSG_INFO, "\t");
|
avrdude_message(msglvl, "\t");
|
||||||
avrdude_message(MSG_INFO, "0x%02x ", (unsigned)buf[i] & 0xFF);
|
avrdude_message(msglvl, "0x%02x ", buf[i]);
|
||||||
if (i % 8 == 3)
|
if (i % 8 == 3)
|
||||||
avrdude_message(MSG_INFO, " ");
|
avrdude_message(msglvl, " ");
|
||||||
else if (i % 8 == 7)
|
else if (i % 8 == 7)
|
||||||
avrdude_message(MSG_INFO, "\n");
|
avrdude_message(msglvl, "\n");
|
||||||
}
|
}
|
||||||
if (i % 8 != 7)
|
if (i % 8 != 7)
|
||||||
avrdude_message(MSG_INFO, "\n");
|
avrdude_message(msglvl, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_send_bin(struct programmer_t *pgm, char *data, size_t len)
|
static int buspirate_send_bin(struct programmer_t *pgm, const unsigned char *data, size_t len)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (verbose > 1) {
|
avrdude_message(MSG_DEBUG, "%s: buspirate_send_bin():\n", progname);
|
||||||
avrdude_message(MSG_INFO, "%s: buspirate_send_bin():\n", progname);
|
dump_mem(MSG_DEBUG, data, len);
|
||||||
dump_mem(data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = serial_send(&pgm->fd, (unsigned char *)data, len);
|
rc = serial_send(&pgm->fd, data, len);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_recv_bin(struct programmer_t *pgm, char *buf, size_t len)
|
static int buspirate_recv_bin(struct programmer_t *pgm, unsigned char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = serial_recv(&pgm->fd, (unsigned char *)buf, len);
|
rc = serial_recv(&pgm->fd, buf, len);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return EOF;
|
return EOF;
|
||||||
if (verbose > 1) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: buspirate_recv_bin():\n", progname);
|
avrdude_message(MSG_DEBUG, "%s: buspirate_recv_bin():\n", progname);
|
||||||
dump_mem(buf, len);
|
dump_mem(MSG_DEBUG, buf, len);
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect_bin(struct programmer_t *pgm,
|
static int buspirate_expect_bin(struct programmer_t *pgm,
|
||||||
char *send_data, size_t send_len,
|
unsigned char *send_data, size_t send_len,
|
||||||
char *expect_data, size_t expect_len)
|
unsigned char *expect_data, size_t expect_len)
|
||||||
{
|
{
|
||||||
char *recv_buf = alloca(expect_len);
|
unsigned char *recv_buf = alloca(expect_len);
|
||||||
if (!pgm->flag & BP_FLAG_IN_BINMODE) {
|
if ((pgm->flag & BP_FLAG_IN_BINMODE) == 0) {
|
||||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode");
|
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +152,7 @@ static int buspirate_expect_bin(struct programmer_t *pgm,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect_bin_byte(struct programmer_t *pgm,
|
static int buspirate_expect_bin_byte(struct programmer_t *pgm,
|
||||||
char send_byte, char expect_byte)
|
unsigned char send_byte, unsigned char expect_byte)
|
||||||
{
|
{
|
||||||
return buspirate_expect_bin(pgm, &send_byte, 1, &expect_byte, 1);
|
return buspirate_expect_bin(pgm, &send_byte, 1, &expect_byte, 1);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +165,7 @@ static int buspirate_getc(struct programmer_t *pgm)
|
||||||
unsigned char ch = 0;
|
unsigned char ch = 0;
|
||||||
|
|
||||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_getc() called from binmode");
|
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_getc() called from binmode\n");
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +203,7 @@ static char *buspirate_readline_noexit(struct programmer_t *pgm, char *buf, size
|
||||||
serial_recv_timeout = PDATA(pgm)->serial_recv_timeout;
|
serial_recv_timeout = PDATA(pgm)->serial_recv_timeout;
|
||||||
}
|
}
|
||||||
serial_recv_timeout = orig_serial_recv_timeout;
|
serial_recv_timeout = orig_serial_recv_timeout;
|
||||||
avrdude_message(MSG_NOTICE, "%s: buspirate_readline(): %s%s",
|
avrdude_message(MSG_DEBUG, "%s: buspirate_readline(): %s%s",
|
||||||
progname, buf,
|
progname, buf,
|
||||||
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
||||||
if (! buf[0])
|
if (! buf[0])
|
||||||
|
@ -227,18 +224,18 @@ static char *buspirate_readline(struct programmer_t *pgm, char *buf, size_t len)
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
static int buspirate_send(struct programmer_t *pgm, char *str)
|
static int buspirate_send(struct programmer_t *pgm, const char *str)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: buspirate_send(): %s", progname, str);
|
avrdude_message(MSG_DEBUG, "%s: buspirate_send(): %s", progname, str);
|
||||||
|
|
||||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send() called from binmode");
|
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send() called from binmode\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = serial_send(&pgm->fd, (unsigned char *)str, strlen(str));
|
rc = serial_send(&pgm->fd, (const unsigned char*)str, strlen(str));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
while (strcmp(buspirate_readline(pgm, NULL, 0), str) != 0)
|
while (strcmp(buspirate_readline(pgm, NULL, 0), str) != 0)
|
||||||
|
@ -248,11 +245,12 @@ static int buspirate_send(struct programmer_t *pgm, char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_is_prompt(char *str)
|
static int buspirate_is_prompt(const char *str)
|
||||||
{
|
{
|
||||||
|
int strlen_str = strlen(str);
|
||||||
/* Prompt ends with '>' or '> '
|
/* Prompt ends with '>' or '> '
|
||||||
* all other input probably ends with '\n' */
|
* all other input probably ends with '\n' */
|
||||||
return (str[strlen(str) - 1] == '>' || str[strlen(str) - 2] == '>');
|
return (str[strlen_str - 1] == '>' || str[strlen_str - 2] == '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect(struct programmer_t *pgm, char *send,
|
static int buspirate_expect(struct programmer_t *pgm, char *send,
|
||||||
|
@ -300,7 +298,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
|
||||||
int serial_recv_timeout;
|
int serial_recv_timeout;
|
||||||
|
|
||||||
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
|
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
|
||||||
extended_param = ldata(ln);
|
extended_param = ldata(ln);
|
||||||
if (strcmp(extended_param, "ascii") == 0) {
|
if (strcmp(extended_param, "ascii") == 0) {
|
||||||
pgm->flag |= BP_FLAG_XPARM_FORCE_ASCII;
|
pgm->flag |= BP_FLAG_XPARM_FORCE_ASCII;
|
||||||
continue;
|
continue;
|
||||||
|
@ -342,7 +340,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sscanf(extended_param, "reset=%s", reset) == 1) {
|
if (sscanf(extended_param, "reset=%9s", reset) == 1) {
|
||||||
char *resetpin;
|
char *resetpin;
|
||||||
while ((resetpin = strtok(preset, ","))) {
|
while ((resetpin = strtok(preset, ","))) {
|
||||||
preset = NULL; /* for subsequent strtok() calls */
|
preset = NULL; /* for subsequent strtok() calls */
|
||||||
|
@ -437,7 +435,7 @@ static void buspirate_close(struct programmer_t *pgm)
|
||||||
|
|
||||||
static void buspirate_reset_from_binmode(struct programmer_t *pgm)
|
static void buspirate_reset_from_binmode(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
char buf[10];
|
unsigned char buf[10];
|
||||||
|
|
||||||
buf[0] = 0x00; /* BinMode: revert to HiZ */
|
buf[0] = 0x00; /* BinMode: revert to HiZ */
|
||||||
buspirate_send_bin(pgm, buf, 1);
|
buspirate_send_bin(pgm, buf, 1);
|
||||||
|
@ -451,7 +449,7 @@ static void buspirate_reset_from_binmode(struct programmer_t *pgm)
|
||||||
int rc;
|
int rc;
|
||||||
rc = buspirate_recv_bin(pgm, buf, sizeof(buf) - 1);
|
rc = buspirate_recv_bin(pgm, buf, sizeof(buf) - 1);
|
||||||
|
|
||||||
if (buspirate_is_prompt(buf)) {
|
if (buspirate_is_prompt((const char*)buf)) {
|
||||||
pgm->flag &= ~BP_FLAG_IN_BINMODE;
|
pgm->flag &= ~BP_FLAG_IN_BINMODE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +478,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
submode = &(const struct submode){
|
submode = &(const struct submode){
|
||||||
.name = "Raw-wire",
|
.name = "Raw-wire",
|
||||||
.enter = 0x05,
|
.enter = 0x05,
|
||||||
.entered_format = "RAW%d",
|
.entered_format = "RAW%1d",
|
||||||
.config = 0x8C,
|
.config = 0x8C,
|
||||||
};
|
};
|
||||||
pgm->flag |= BP_FLAG_NOPAGEDWRITE;
|
pgm->flag |= BP_FLAG_NOPAGEDWRITE;
|
||||||
|
@ -489,7 +487,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
submode = &(const struct submode){
|
submode = &(const struct submode){
|
||||||
.name = "SPI",
|
.name = "SPI",
|
||||||
.enter = 0x01,
|
.enter = 0x01,
|
||||||
.entered_format = "SPI%d",
|
.entered_format = "SPI%1d",
|
||||||
|
|
||||||
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
||||||
* we want: 3.3V(1), idle low(0), data change on
|
* we want: 3.3V(1), idle low(0), data change on
|
||||||
|
@ -499,9 +497,8 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
.config = 0x8A,
|
.config = 0x8A,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[20] = { '\0' };
|
unsigned char buf[20] = { '\0' };
|
||||||
unsigned int ver = 0;
|
|
||||||
|
|
||||||
/* == Switch to binmode - send 20x '\0' == */
|
/* == Switch to binmode - send 20x '\0' == */
|
||||||
buspirate_send_bin(pgm, buf, sizeof(buf));
|
buspirate_send_bin(pgm, buf, sizeof(buf));
|
||||||
|
@ -509,7 +506,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
/* Expecting 'BBIOx' reply */
|
/* Expecting 'BBIOx' reply */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buspirate_recv_bin(pgm, buf, 5);
|
buspirate_recv_bin(pgm, buf, 5);
|
||||||
if (sscanf(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) {
|
if (sscanf((const char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) {
|
||||||
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
||||||
buspirate_reset_from_binmode(pgm);
|
buspirate_reset_from_binmode(pgm);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -524,7 +521,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
buspirate_send_bin(pgm, buf, 1);
|
buspirate_send_bin(pgm, buf, 1);
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buspirate_recv_bin(pgm, buf, 4);
|
buspirate_recv_bin(pgm, buf, 4);
|
||||||
if (sscanf(buf, submode->entered_format,
|
if (sscanf((const char*)buf, submode->entered_format,
|
||||||
&PDATA(pgm)->submode_version) != 1) {
|
&PDATA(pgm)->submode_version) != 1) {
|
||||||
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
|
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
|
||||||
submode->name, buf);
|
submode->name, buf);
|
||||||
|
@ -539,8 +536,8 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
pgm->paged_write = NULL;
|
pgm->paged_write = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* Check for write-then-read without !CS/CS and disable paged_write if absent: */
|
/* Check for write-then-read without !CS/CS and disable paged_write if absent: */
|
||||||
strncpy(buf, "\x5\x0\x0\x0\x0", 5);
|
static const unsigned char buf2[] = {5,0,0,0,0};
|
||||||
buspirate_send_bin(pgm, buf, 5);
|
buspirate_send_bin(pgm, buf2, sizeof(buf2));
|
||||||
buspirate_recv_bin(pgm, buf, 1);
|
buspirate_recv_bin(pgm, buf, 1);
|
||||||
if (buf[0] != 0x01) {
|
if (buf[0] != 0x01) {
|
||||||
|
|
||||||
|
@ -585,8 +582,9 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (rv) {
|
if (rv) {
|
||||||
strncpy(buf, "\x1\x0\x0", 3);
|
unsigned int ver = 0;
|
||||||
buspirate_send_bin(pgm, buf, 1);
|
static const unsigned char buf2[] = {1};
|
||||||
|
buspirate_send_bin(pgm, buf2, sizeof(buf2));
|
||||||
buspirate_recv_bin(pgm, buf, 3);
|
buspirate_recv_bin(pgm, buf, 3);
|
||||||
ver = buf[1] << 8 | buf[2];
|
ver = buf[1] << 8 | buf[2];
|
||||||
avrdude_message(MSG_NOTICE, "AVR Extended Commands version %d\n", ver);
|
avrdude_message(MSG_NOTICE, "AVR Extended Commands version %d\n", ver);
|
||||||
|
@ -604,12 +602,14 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
int spi_cmd = -1;
|
int spi_cmd = -1;
|
||||||
int cmd;
|
int cmd;
|
||||||
char *rcvd, mode[11], buf[5];
|
char *rcvd;
|
||||||
|
char buf[5];
|
||||||
|
char mode[11];
|
||||||
|
|
||||||
buspirate_send(pgm, "m\n");
|
buspirate_send(pgm, "m\n");
|
||||||
while(1) {
|
while(1) {
|
||||||
rcvd = buspirate_readline(pgm, NULL, 0);
|
rcvd = buspirate_readline(pgm, NULL, 0);
|
||||||
if (spi_cmd == -1 && sscanf(rcvd, "%d. %10s", &cmd, mode)) {
|
if (spi_cmd == -1 && sscanf(rcvd, "%2d. %10s", &cmd, mode)) {
|
||||||
if (strcmp(mode, "SPI") == 0)
|
if (strcmp(mode, "SPI") == 0)
|
||||||
spi_cmd = cmd;
|
spi_cmd = cmd;
|
||||||
}
|
}
|
||||||
|
@ -632,12 +632,12 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
|
||||||
/* BP firmware 2.1 defaults to Open-drain output.
|
/* BP firmware 2.1 defaults to Open-drain output.
|
||||||
* That doesn't work on my board, even with pull-up
|
* That doesn't work on my board, even with pull-up
|
||||||
* resistors. Select 3.3V output mode instead. */
|
* resistors. Select 3.3V output mode instead. */
|
||||||
sscanf(rcvd, " %d.", &cmd);
|
sscanf(rcvd, " %2d.", &cmd);
|
||||||
snprintf(buf, sizeof(buf), "%d\n", cmd);
|
snprintf(buf, sizeof(buf), "%d\n", cmd);
|
||||||
}
|
}
|
||||||
if (buspirate_is_prompt(rcvd)) {
|
if (buspirate_is_prompt(rcvd)) {
|
||||||
if (strncmp(rcvd, "SPI>", 4) == 0) {
|
if (strncmp(rcvd, "SPI>", 4) == 0) {
|
||||||
if (verbose) avrdude_message(MSG_INFO, "BusPirate is now configured for SPI\n");
|
avrdude_message(MSG_INFO, "BusPirate is now configured for SPI\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Not yet 'SPI>' prompt */
|
/* Not yet 'SPI>' prompt */
|
||||||
|
@ -653,8 +653,8 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
|
||||||
|
|
||||||
static void buspirate_enable(struct programmer_t *pgm)
|
static void buspirate_enable(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
unsigned char *reset_str = "#\n";
|
static const char *reset_str = "#\n";
|
||||||
unsigned char *accept_str = "y\n";
|
static const char *accept_str = "y\n";
|
||||||
char *rcvd;
|
char *rcvd;
|
||||||
int rc, print_banner = 0;
|
int rc, print_banner = 0;
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ static void buspirate_enable(struct programmer_t *pgm)
|
||||||
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate binary mode...\n");
|
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate binary mode...\n");
|
||||||
|
|
||||||
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
|
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
|
||||||
buspirate_send_bin(pgm, "\n\n", 2);
|
buspirate_send_bin(pgm, (const unsigned char*)"\n\n", 2);
|
||||||
|
|
||||||
/* Clear input buffer: */
|
/* Clear input buffer: */
|
||||||
serial_drain(&pgm->fd, 0);
|
serial_drain(&pgm->fd, 0);
|
||||||
|
@ -683,7 +683,7 @@ static void buspirate_enable(struct programmer_t *pgm)
|
||||||
|
|
||||||
/* Call buspirate_send_bin() instead of buspirate_send()
|
/* Call buspirate_send_bin() instead of buspirate_send()
|
||||||
* because we don't know if BP is in text or bin mode */
|
* because we don't know if BP is in text or bin mode */
|
||||||
rc = buspirate_send_bin(pgm, reset_str, strlen(reset_str));
|
rc = buspirate_send_bin(pgm, (const unsigned char*)reset_str, strlen(reset_str));
|
||||||
if (rc) {
|
if (rc) {
|
||||||
avrdude_message(MSG_INFO, "BusPirate is not responding. Serial port error: %d\n", rc);
|
avrdude_message(MSG_INFO, "BusPirate is not responding. Serial port error: %d\n", rc);
|
||||||
return;
|
return;
|
||||||
|
@ -696,18 +696,18 @@ static void buspirate_enable(struct programmer_t *pgm)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strncmp(rcvd, "Are you sure?", 13) == 0) {
|
if (strncmp(rcvd, "Are you sure?", 13) == 0) {
|
||||||
buspirate_send_bin(pgm, accept_str, strlen(accept_str));
|
buspirate_send_bin(pgm, (const unsigned char*)accept_str, strlen(accept_str));
|
||||||
}
|
}
|
||||||
if (strncmp(rcvd, "RESET", 5) == 0) {
|
if (strncmp(rcvd, "RESET", 5) == 0) {
|
||||||
print_banner = 1;
|
print_banner = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (buspirate_is_prompt(rcvd)) {
|
if (buspirate_is_prompt(rcvd)) {
|
||||||
puts("**");
|
avrdude_message(MSG_DEBUG, "**\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (print_banner)
|
if (print_banner)
|
||||||
avrdude_message(MSG_INFO, "** %s", rcvd);
|
avrdude_message(MSG_DEBUG, "** %s", rcvd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
|
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
|
||||||
|
@ -797,8 +797,8 @@ static int buspirate_cmd_bin(struct programmer_t *pgm,
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
buspirate_send_bin(pgm, (char *)cmd, 4);
|
buspirate_send_bin(pgm, cmd, 4);
|
||||||
buspirate_recv_bin(pgm, (char *)res, 4);
|
buspirate_recv_bin(pgm, res, 4);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -817,7 +817,7 @@ static int buspirate_cmd_ascii(struct programmer_t *pgm,
|
||||||
while (i < 4) {
|
while (i < 4) {
|
||||||
rcvd = buspirate_readline(pgm, NULL, 0);
|
rcvd = buspirate_readline(pgm, NULL, 0);
|
||||||
/* WRITE: 0xAC READ: 0x04 */
|
/* WRITE: 0xAC READ: 0x04 */
|
||||||
if (sscanf(rcvd, "WRITE: 0x%x READ: 0x%x", &spi_write, &spi_read) == 2) {
|
if (sscanf(rcvd, "WRITE: 0x%2x READ: 0x%2x", &spi_write, &spi_read) == 2) {
|
||||||
res[i++] = spi_read;
|
res[i++] = spi_read;
|
||||||
}
|
}
|
||||||
if (buspirate_is_prompt(rcvd))
|
if (buspirate_is_prompt(rcvd))
|
||||||
|
@ -873,7 +873,8 @@ static int buspirate_paged_load(
|
||||||
}
|
}
|
||||||
|
|
||||||
// send command to read data
|
// send command to read data
|
||||||
strncpy(commandbuf, "\x6\x2", 2);
|
commandbuf[0] = 6;
|
||||||
|
commandbuf[1] = 2;
|
||||||
|
|
||||||
// send start address (in WORDS, not bytes!)
|
// send start address (in WORDS, not bytes!)
|
||||||
commandbuf[2] = (address >> 1 >> 24) & 0xff;
|
commandbuf[2] = (address >> 1 >> 24) & 0xff;
|
||||||
|
@ -896,7 +897,7 @@ static int buspirate_paged_load(
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (addr = 0; addr < n_bytes; addr++) {
|
for (addr = 0; addr < n_bytes; addr++) {
|
||||||
buspirate_recv_bin(pgm, &m->buf[addr+address], 1);
|
buspirate_recv_bin(pgm, &m->buf[addr+address], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,8 +915,8 @@ static int buspirate_paged_write(struct programmer_t *pgm,
|
||||||
int addr = base_addr;
|
int addr = base_addr;
|
||||||
int n_page_writes;
|
int n_page_writes;
|
||||||
int this_page_size;
|
int this_page_size;
|
||||||
char cmd_buf[4096] = {'\0'};
|
unsigned char cmd_buf[4096] = {'\0'};
|
||||||
char send_byte, recv_byte;
|
unsigned char send_byte, recv_byte;
|
||||||
|
|
||||||
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
|
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
|
||||||
/* Return if we are not in binary mode. */
|
/* Return if we are not in binary mode. */
|
||||||
|
@ -1130,7 +1131,7 @@ void buspirate_initpgm(struct programmer_t *pgm)
|
||||||
|
|
||||||
static void buspirate_bb_enable(struct programmer_t *pgm)
|
static void buspirate_bb_enable(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
char buf[20] = { '\0' };
|
unsigned char buf[20] = { '\0' };
|
||||||
|
|
||||||
if (bitbang_check_prerequisites(pgm) < 0)
|
if (bitbang_check_prerequisites(pgm) < 0)
|
||||||
return; /* XXX should treat as error */
|
return; /* XXX should treat as error */
|
||||||
|
@ -1138,7 +1139,7 @@ static void buspirate_bb_enable(struct programmer_t *pgm)
|
||||||
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate bitbang binary mode...\n");
|
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate bitbang binary mode...\n");
|
||||||
|
|
||||||
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
|
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
|
||||||
buspirate_send_bin(pgm, "\n\n", 2);
|
buspirate_send_bin(pgm, (const unsigned char*)"\n\n", 2);
|
||||||
|
|
||||||
/* Clear input buffer: */
|
/* Clear input buffer: */
|
||||||
serial_drain(&pgm->fd, 0);
|
serial_drain(&pgm->fd, 0);
|
||||||
|
@ -1149,7 +1150,7 @@ static void buspirate_bb_enable(struct programmer_t *pgm)
|
||||||
/* Expecting 'BBIOx' reply */
|
/* Expecting 'BBIOx' reply */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buspirate_recv_bin(pgm, buf, 5);
|
buspirate_recv_bin(pgm, buf, 5);
|
||||||
if (sscanf(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) {
|
if (sscanf((char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) {
|
||||||
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
||||||
buspirate_reset_from_binmode(pgm);
|
buspirate_reset_from_binmode(pgm);
|
||||||
return;
|
return;
|
||||||
|
@ -1219,8 +1220,7 @@ static int buspirate_bb_getpin(struct programmer_t *pgm, int pinfunc)
|
||||||
if (buf[0] & (1 << (pin - 1)))
|
if (buf[0] & (1 << (pin - 1)))
|
||||||
value ^= 1;
|
value ^= 1;
|
||||||
|
|
||||||
if (verbose > 1)
|
avrdude_message(MSG_DEBUG, "get pin %d = %d\n", pin, value);
|
||||||
printf("get pin %d = %d\n", pin, value);
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -1237,8 +1237,7 @@ static int buspirate_bb_setpin_internal(struct programmer_t *pgm, int pin, int v
|
||||||
if ((pin < 1 || pin > 5) && (pin != 7)) // 7 is POWER
|
if ((pin < 1 || pin > 5) && (pin != 7)) // 7 is POWER
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (verbose > 1)
|
avrdude_message(MSG_DEBUG, "set pin %d = %d\n", pin, value);
|
||||||
printf("set pin %d = %d\n", pin, value);
|
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
PDATA(pgm)->pin_val |= (1 << (pin - 1));
|
PDATA(pgm)->pin_val |= (1 << (pin - 1));
|
||||||
|
|
|
@ -555,6 +555,11 @@ prog_parm_usb:
|
||||||
|
|
||||||
usb_pid_list:
|
usb_pid_list:
|
||||||
TKN_NUMBER {
|
TKN_NUMBER {
|
||||||
|
{
|
||||||
|
/* overwrite pids, so clear the existing entries */
|
||||||
|
ldestroy_cb(current_prog->usbpid, free);
|
||||||
|
current_prog->usbpid = lcreat(NULL, 0);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
int *ip = malloc(sizeof(int));
|
int *ip = malloc(sizeof(int));
|
||||||
if (ip) {
|
if (ip) {
|
||||||
|
|
3
dfu.c
3
dfu.c
|
@ -139,7 +139,8 @@ struct dfu_dev * dfu_open(char *port_spec)
|
||||||
if (dfu == NULL)
|
if (dfu == NULL)
|
||||||
{
|
{
|
||||||
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
|
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
|
||||||
return 0;
|
free(bus_name);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dfu->bus_name = bus_name;
|
dfu->bus_name = bus_name;
|
||||||
|
|
7
fileio.c
7
fileio.c
|
@ -1493,6 +1493,8 @@ int fileio(int op, char * filename, FILEFMT format,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format == FMT_AUTO) {
|
if (format == FMT_AUTO) {
|
||||||
|
int format_detect;
|
||||||
|
|
||||||
if (using_stdio) {
|
if (using_stdio) {
|
||||||
avrdude_message(MSG_INFO, "%s: can't auto detect file format when using stdin/out.\n"
|
avrdude_message(MSG_INFO, "%s: can't auto detect file format when using stdin/out.\n"
|
||||||
"%s Please specify a file format and try again.\n",
|
"%s Please specify a file format and try again.\n",
|
||||||
|
@ -1500,12 +1502,13 @@ int fileio(int op, char * filename, FILEFMT format,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
format = fmt_autodetect(fname);
|
format_detect = fmt_autodetect(fname);
|
||||||
if (format < 0) {
|
if (format_detect < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n",
|
avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n",
|
||||||
progname, fname);
|
progname, fname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
format = format_detect;
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: %s file %s auto detected as %s\n",
|
avrdude_message(MSG_INFO, "%s: %s file %s auto detected as %s\n",
|
||||||
|
|
|
@ -545,7 +545,7 @@ struct serial_device
|
||||||
int (*setspeed)(union filedescriptor *fd, long baud);
|
int (*setspeed)(union filedescriptor *fd, long baud);
|
||||||
void (*close)(union filedescriptor *fd);
|
void (*close)(union filedescriptor *fd);
|
||||||
|
|
||||||
int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
int (*send)(union filedescriptor *fd, const unsigned char * buf, size_t buflen);
|
||||||
int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
||||||
int (*drain)(union filedescriptor *fd, int display);
|
int (*drain)(union filedescriptor *fd, int display);
|
||||||
|
|
||||||
|
|
46
pickit2.c
46
pickit2.c
|
@ -75,13 +75,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DEBUG(...) do { avrdude_message(MSG_INFO, __VA_ARGS__); } while(0)
|
#define DEBUG(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0)
|
||||||
#else
|
#else
|
||||||
#define DEBUG(...) ((void)0)
|
#define DEBUG(...) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DEBUGRECV(...) do { avrdude_message(MSG_INFO, __VA_ARGS__); } while(0)
|
#define DEBUGRECV(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0)
|
||||||
#else
|
#else
|
||||||
#define DEBUGRECV(...) ((void)0)
|
#define DEBUGRECV(...) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,7 +108,7 @@ static int usb_open_device(struct usb_dev_handle **dev, int vid, int pid);
|
||||||
#define USB_ERROR_IO 5
|
#define USB_ERROR_IO 5
|
||||||
#endif // WIN32NATIVE
|
#endif // WIN32NATIVE
|
||||||
|
|
||||||
static int pickit2_write_report(PROGRAMMER *pgm, unsigned char report[65]);
|
static int pickit2_write_report(PROGRAMMER *pgm, const unsigned char report[65]);
|
||||||
static int pickit2_read_report(PROGRAMMER *pgm, unsigned char report[65]);
|
static int pickit2_read_report(PROGRAMMER *pgm, unsigned char report[65]);
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
|
@ -198,14 +198,14 @@ static int pickit2_open(PROGRAMMER * pgm, char * port)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get the device description while we're at it
|
// get the device description while we're at it
|
||||||
short buff[PGM_DESCLEN], i;
|
short buff[PGM_DESCLEN-1], i;
|
||||||
HidD_GetProductString(PDATA(pgm)->usb_handle, buff, PGM_DESCLEN);
|
HidD_GetProductString(PDATA(pgm)->usb_handle, buff, PGM_DESCLEN-1);
|
||||||
|
|
||||||
// convert from wide chars
|
// convert from wide chars, but do not overwrite trailing '\0'
|
||||||
memset(&(pgm->type), 0, PGM_DESCLEN);
|
memset(&(pgm->type), 0, PGM_DESCLEN);
|
||||||
for (i = 0; i < PGM_DESCLEN && buff[i]; i++)
|
for (i = 0; i < (PGM_DESCLEN-1) && buff[i]; i++)
|
||||||
{
|
{
|
||||||
pgm->type[i] = (char)buff[i];
|
pgm->type[i] = (char)buff[i]; // TODO what about little/big endian???
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -255,17 +255,18 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||||
pgm->set_sck_period(pgm, pgm->bitclock);
|
pgm->set_sck_period(pgm, pgm->bitclock);
|
||||||
|
|
||||||
/* connect to target device -- we'll just ask for the firmware version */
|
/* connect to target device -- we'll just ask for the firmware version */
|
||||||
char report[65] = {0, CMD_GET_VERSION, CMD_END_OF_BUFFER};
|
static const unsigned char report[65] = {0, CMD_GET_VERSION, CMD_END_OF_BUFFER};
|
||||||
if ((errorCode = pickit2_write_report(pgm, report)) > 0)
|
if ((errorCode = pickit2_write_report(pgm, report)) > 0)
|
||||||
{
|
{
|
||||||
memset(report, 0, sizeof(report));
|
unsigned char report[65] = {0};
|
||||||
|
//memset(report, 0, sizeof(report));
|
||||||
if ((errorCode = pickit2_read_report(pgm, report)) >= 4)
|
if ((errorCode = pickit2_read_report(pgm, report)) >= 4)
|
||||||
{
|
{
|
||||||
avrdude_message(MSG_NOTICE, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
avrdude_message(MSG_NOTICE, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||||
|
|
||||||
// set the pins, apply reset,
|
// set the pins, apply reset,
|
||||||
// TO DO: apply vtarget (if requested though -x option)
|
// TO DO: apply vtarget (if requested though -x option)
|
||||||
char report[65] =
|
unsigned char report[65] =
|
||||||
{
|
{
|
||||||
0, CMD_SET_VDD_4(5),
|
0, CMD_SET_VDD_4(5),
|
||||||
CMD_SET_VPP_4(5),
|
CMD_SET_VPP_4(5),
|
||||||
|
@ -321,7 +322,7 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||||
static void pickit2_disable(PROGRAMMER * pgm)
|
static void pickit2_disable(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
/* make sure all pins are floating & all voltages are off */
|
/* make sure all pins are floating & all voltages are off */
|
||||||
uint8_t report[65] =
|
static const unsigned char report[65] =
|
||||||
{
|
{
|
||||||
0, CMD_EXEC_SCRIPT_2(8),
|
0, CMD_EXEC_SCRIPT_2(8),
|
||||||
SCR_SET_PINS_2(1,1,0,0),
|
SCR_SET_PINS_2(1,1,0,0),
|
||||||
|
@ -430,16 +431,15 @@ static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p)
|
||||||
avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd);
|
avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd);
|
||||||
pgm->cmd(pgm, cmd, res);
|
pgm->cmd(pgm, cmd, res);
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
avrdude_message(MSG_NOTICE, "program_enable(): sending command. Resp = ");
|
avrdude_message(MSG_DEBUG, "program_enable(): sending command. Resp = ");
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
avrdude_message(MSG_NOTICE, "%x ", (int)res[i]);
|
avrdude_message(MSG_DEBUG, "%x ", (int)res[i]);
|
||||||
}
|
}
|
||||||
avrdude_message(MSG_NOTICE, "\n");
|
avrdude_message(MSG_DEBUG, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for sync character
|
// check for sync character
|
||||||
|
@ -837,7 +837,7 @@ static HANDLE open_hid(unsigned short vid, unsigned short pid)
|
||||||
LONG Result;
|
LONG Result;
|
||||||
|
|
||||||
// were global, now just local scrap
|
// were global, now just local scrap
|
||||||
int Length = 0;
|
DWORD Length = 0;
|
||||||
PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = NULL;
|
PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = NULL;
|
||||||
HANDLE DeviceHandle=NULL;
|
HANDLE DeviceHandle=NULL;
|
||||||
GUID HidGuid;
|
GUID HidGuid;
|
||||||
|
@ -1087,7 +1087,7 @@ static int usb_read_interrupt(PROGRAMMER *pgm, void *buff, int size, int timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple write with timeout
|
// simple write with timeout
|
||||||
static int usb_write_interrupt(PROGRAMMER *pgm, void *buff, int size, int timeout)
|
static int usb_write_interrupt(PROGRAMMER *pgm, const void *buff, int size, int timeout)
|
||||||
{
|
{
|
||||||
OVERLAPPED ovr;
|
OVERLAPPED ovr;
|
||||||
DWORD bytesWritten = 0;
|
DWORD bytesWritten = 0;
|
||||||
|
@ -1112,9 +1112,9 @@ static int usb_write_interrupt(PROGRAMMER *pgm, void *buff, int size, int timeou
|
||||||
return bytesWritten > 0 ? bytesWritten : -1;
|
return bytesWritten > 0 ? bytesWritten : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pickit2_write_report(PROGRAMMER * pgm, unsigned char report[65])
|
static int pickit2_write_report(PROGRAMMER * pgm, const unsigned char report[65])
|
||||||
{
|
{
|
||||||
return usb_write_interrupt(pgm, report, 65, PDATA(pgm)->transaction_timeout);
|
return usb_write_interrupt(pgm, report, 65, PDATA(pgm)->transaction_timeout); // XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65])
|
static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65])
|
||||||
|
@ -1183,16 +1183,16 @@ static int usb_open_device(struct usb_dev_handle **device, int vendor, int produ
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pickit2_write_report(PROGRAMMER * pgm, unsigned char report[65])
|
static int pickit2_write_report(PROGRAMMER * pgm, const unsigned char report[65])
|
||||||
{
|
{
|
||||||
// endpoint 1 OUT??
|
// endpoint 1 OUT??
|
||||||
return usb_interrupt_write(PDATA(pgm)->usb_handle, USB_ENDPOINT_OUT | 1, report+1, 64, PDATA(pgm)->transaction_timeout);
|
return usb_interrupt_write(PDATA(pgm)->usb_handle, USB_ENDPOINT_OUT | 1, (const char*)(report+1), 64, PDATA(pgm)->transaction_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65])
|
static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65])
|
||||||
{
|
{
|
||||||
// endpoint 1 IN??
|
// endpoint 1 IN??
|
||||||
return usb_interrupt_read(PDATA(pgm)->usb_handle, USB_ENDPOINT_IN | 1, report+1, 64, PDATA(pgm)->transaction_timeout);
|
return usb_interrupt_read(PDATA(pgm)->usb_handle, USB_ENDPOINT_IN | 1, (char*)(report+1), 64, PDATA(pgm)->transaction_timeout);
|
||||||
}
|
}
|
||||||
#endif // WIN323NATIVE
|
#endif // WIN323NATIVE
|
||||||
|
|
||||||
|
|
90
safemode.c
90
safemode.c
|
@ -27,10 +27,10 @@
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
/* This value from ac_cfg.h */
|
/* This value from ac_cfg.h */
|
||||||
/*
|
/*
|
||||||
* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or
|
* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or
|
||||||
* "efuse") and verifies it. Will try up to tries amount of times
|
* "efuse") and verifies it. Will try up to tries amount of times
|
||||||
* before giving up
|
* before giving up
|
||||||
*/
|
*/
|
||||||
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
||||||
AVRPART * p, int tries)
|
AVRPART * p, int tries)
|
||||||
|
@ -38,13 +38,13 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
||||||
AVRMEM * m;
|
AVRMEM * m;
|
||||||
unsigned char fuseread;
|
unsigned char fuseread;
|
||||||
int returnvalue = -1;
|
int returnvalue = -1;
|
||||||
|
|
||||||
m = avr_locate_mem(p, fusename);
|
m = avr_locate_mem(p, fusename);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep trying to write then read back the fuse values */
|
/* Keep trying to write then read back the fuse values */
|
||||||
while (tries > 0) {
|
while (tries > 0) {
|
||||||
if (avr_write_byte(pgm, p, m, 0, fuse) != 0)
|
if (avr_write_byte(pgm, p, m, 0, fuse) != 0)
|
||||||
{
|
{
|
||||||
|
@ -54,11 +54,11 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report information to user if needed */
|
/* Report information to user if needed */
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
|
avrdude_message(MSG_NOTICE, "%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
|
||||||
progname, fusename, fuse, fuseread, tries-1);
|
progname, fusename, fuse, fuseread, tries-1);
|
||||||
|
|
||||||
/* If fuse wrote OK, no need to keep going */
|
/* If fuse wrote OK, no need to keep going */
|
||||||
if (fuse == fuseread) {
|
if (fuse == fuseread) {
|
||||||
tries = 0;
|
tries = 0;
|
||||||
|
@ -66,17 +66,17 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
||||||
}
|
}
|
||||||
tries--;
|
tries--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnvalue;
|
return returnvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads the fuses three times, checking that all readings are the
|
* Reads the fuses three times, checking that all readings are the
|
||||||
* same. This will ensure that the before values aren't in error!
|
* same. This will ensure that the before values aren't in error!
|
||||||
*/
|
*/
|
||||||
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
unsigned char * efuse, unsigned char * fuse,
|
unsigned char * efuse, unsigned char * fuse,
|
||||||
PROGRAMMER * pgm, AVRPART * p)
|
PROGRAMMER * pgm, AVRPART * p)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char value;
|
unsigned char value;
|
||||||
|
@ -87,14 +87,14 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
unsigned char safemode_efuse;
|
unsigned char safemode_efuse;
|
||||||
unsigned char safemode_fuse;
|
unsigned char safemode_fuse;
|
||||||
AVRMEM * m;
|
AVRMEM * m;
|
||||||
|
|
||||||
safemode_lfuse = *lfuse;
|
safemode_lfuse = *lfuse;
|
||||||
safemode_hfuse = *hfuse;
|
safemode_hfuse = *hfuse;
|
||||||
safemode_efuse = *efuse;
|
safemode_efuse = *efuse;
|
||||||
safemode_fuse = *fuse;
|
safemode_fuse = *fuse;
|
||||||
|
|
||||||
|
|
||||||
/* Read fuse three times */
|
/* Read fuse three times */
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
||||||
to generate a verify error */
|
to generate a verify error */
|
||||||
m = avr_locate_mem(p, "fuse");
|
m = avr_locate_mem(p, "fuse");
|
||||||
|
@ -121,25 +121,25 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
fusegood = 1; /* Fuse read OK three times */
|
fusegood = 1; /* Fuse read OK three times */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
//Programmer does not allow fuse reading.... no point trying anymore
|
||||||
if (allowfuseread == 0)
|
if (allowfuseread == 0)
|
||||||
{
|
{
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fusegood == 0) {
|
if (fusegood == 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read fuse properly. "
|
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read fuse properly. "
|
||||||
"Programmer may not be reliable.\n", progname);
|
"Programmer may not be reliable.\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if ((fusegood == 1)) {
|
else if (fusegood == 1) {
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
|
avrdude_message(MSG_NOTICE, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read lfuse three times */
|
/* Read lfuse three times */
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
||||||
to generate a verify error */
|
to generate a verify error */
|
||||||
m = avr_locate_mem(p, "lfuse");
|
m = avr_locate_mem(p, "lfuse");
|
||||||
|
@ -167,14 +167,14 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
//Programmer does not allow fuse reading.... no point trying anymore
|
||||||
if (allowfuseread == 0)
|
if (allowfuseread == 0)
|
||||||
{
|
{
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fusegood == 0) {
|
if (fusegood == 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read lfuse properly. "
|
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read lfuse properly. "
|
||||||
"Programmer may not be reliable.\n", progname);
|
"Programmer may not be reliable.\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -183,7 +183,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
|
avrdude_message(MSG_DEBUG, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read hfuse three times */
|
/* Read hfuse three times */
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
||||||
to generate a verify error */
|
to generate a verify error */
|
||||||
m = avr_locate_mem(p, "hfuse");
|
m = avr_locate_mem(p, "hfuse");
|
||||||
|
@ -211,11 +211,11 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
//Programmer does not allow fuse reading.... no point trying anymore
|
||||||
if (allowfuseread == 0)
|
if (allowfuseread == 0)
|
||||||
{
|
{
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fusegood == 0) {
|
if (fusegood == 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read hfuse properly. "
|
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read hfuse properly. "
|
||||||
|
@ -226,7 +226,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
|
avrdude_message(MSG_NOTICE, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read efuse three times */
|
/* Read efuse three times */
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
||||||
to generate a verify error */
|
to generate a verify error */
|
||||||
m = avr_locate_mem(p, "efuse");
|
m = avr_locate_mem(p, "efuse");
|
||||||
|
@ -253,14 +253,14 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
//Programmer does not allow fuse reading.... no point trying anymore
|
||||||
if (allowfuseread == 0)
|
if (allowfuseread == 0)
|
||||||
{
|
{
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fusegood == 0) {
|
if (fusegood == 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read efuse properly. "
|
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read efuse properly. "
|
||||||
"Programmer may not be reliable.\n", progname);
|
"Programmer may not be reliable.\n", progname);
|
||||||
return -3;
|
return -3;
|
||||||
|
@ -294,11 +294,11 @@ int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse,
|
||||||
static unsigned char safemode_hfuse = 0xff;
|
static unsigned char safemode_hfuse = 0xff;
|
||||||
static unsigned char safemode_efuse = 0xff;
|
static unsigned char safemode_efuse = 0xff;
|
||||||
static unsigned char safemode_fuse = 0xff;
|
static unsigned char safemode_fuse = 0xff;
|
||||||
|
|
||||||
switch (save) {
|
switch (save) {
|
||||||
|
|
||||||
/* Save the fuses as safemode setting */
|
/* Save the fuses as safemode setting */
|
||||||
case 1:
|
case 1:
|
||||||
safemode_lfuse = *lfuse;
|
safemode_lfuse = *lfuse;
|
||||||
safemode_hfuse = *hfuse;
|
safemode_hfuse = *hfuse;
|
||||||
safemode_efuse = *efuse;
|
safemode_efuse = *efuse;
|
||||||
|
@ -313,6 +313,6 @@ int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse,
|
||||||
*fuse = safemode_fuse;
|
*fuse = safemode_fuse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,7 @@ static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNum
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void dumpBlock(char *prefix, unsigned char *buf, int len)
|
static void dumpBlock(const char *prefix, const unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ static int chooseDataSize(int len)
|
||||||
return i - 1;
|
return i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int avrdoper_send(union filedescriptor *fdp, unsigned char *buf, size_t buflen)
|
static int avrdoper_send(union filedescriptor *fdp, const unsigned char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
if(verbose > 3)
|
if(verbose > 3)
|
||||||
dumpBlock("Send", buf, buflen);
|
dumpBlock("Send", buf, buflen);
|
||||||
|
|
|
@ -309,10 +309,10 @@ static void ser_close(union filedescriptor *fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
|
static int ser_send(union filedescriptor *fd, const unsigned char * buf, size_t buflen)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned char * p = buf;
|
const unsigned char * p = buf;
|
||||||
size_t len = buflen;
|
size_t len = buflen;
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
|
|
|
@ -220,12 +220,12 @@ static int ser_set_dtr_rts(union filedescriptor *fd, int is_on)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
|
static int ser_send(union filedescriptor *fd, const unsigned char * buf, size_t buflen)
|
||||||
{
|
{
|
||||||
size_t len = buflen;
|
size_t len = buflen;
|
||||||
unsigned char c='\0';
|
unsigned char c='\0';
|
||||||
DWORD written;
|
DWORD written;
|
||||||
unsigned char * b = buf;
|
const unsigned char * b = buf;
|
||||||
|
|
||||||
HANDLE hComPort=(HANDLE)fd->pfd;
|
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||||
|
|
||||||
|
|
|
@ -3194,7 +3194,7 @@ f_to_kHz_MHz(double f, const char **unit)
|
||||||
|
|
||||||
static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p)
|
static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p)
|
||||||
{
|
{
|
||||||
unsigned char vtarget, vadjust, osc_pscale, osc_cmatch, sck_duration;
|
unsigned char vtarget, vadjust, osc_pscale, osc_cmatch, sck_duration =0; //XXX 0 is not correct, check caller
|
||||||
unsigned int sck_stk600, clock_conf, dac, oct, varef;
|
unsigned int sck_stk600, clock_conf, dac, oct, varef;
|
||||||
unsigned char vtarget_jtag[4];
|
unsigned char vtarget_jtag[4];
|
||||||
int prescale;
|
int prescale;
|
||||||
|
|
24
usb_libusb.c
24
usb_libusb.c
|
@ -321,12 +321,12 @@ static void usbdev_close(union filedescriptor *fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int usbdev_send(union filedescriptor *fd, unsigned char *bp, size_t mlen)
|
static int usbdev_send(union filedescriptor *fd, const unsigned char *bp, size_t mlen)
|
||||||
{
|
{
|
||||||
usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle;
|
usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle;
|
||||||
int rv;
|
int rv;
|
||||||
int i = mlen;
|
int i = mlen;
|
||||||
unsigned char * p = bp;
|
const unsigned char * p = bp;
|
||||||
int tx_size;
|
int tx_size;
|
||||||
|
|
||||||
if (udev == NULL)
|
if (udev == NULL)
|
||||||
|
@ -514,14 +514,30 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
|
||||||
memcpy (buf, usbbuf, rv);
|
memcpy (buf, usbbuf, rv);
|
||||||
buf += rv;
|
buf += rv;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1; // buffer overflow
|
||||||
|
}
|
||||||
|
|
||||||
n += rv;
|
n += rv;
|
||||||
nbytes -= rv;
|
nbytes -= rv;
|
||||||
}
|
}
|
||||||
while (nbytes > 0 && rv == fd->usb.max_xfer);
|
while (nbytes > 0 && rv == fd->usb.max_xfer);
|
||||||
|
|
||||||
if (nbytes < 0)
|
/*
|
||||||
return -1;
|
this ends when the buffer is completly filled (nbytes=0) or was too small (nbytes< 0)
|
||||||
|
or a short packet is found.
|
||||||
|
however we cannot say for nbytes=0 that there was really a packet completed,
|
||||||
|
we had to check the last rv value than for a short packet,
|
||||||
|
but what happens if the packet does not end with a short packet?
|
||||||
|
and what if the buffer is filled without the packet was completed?
|
||||||
|
|
||||||
|
preconditions:
|
||||||
|
expected packet is not a multiple of usb.max_xfer. (prevents further waiting)
|
||||||
|
|
||||||
|
expected packet is shorter than the provided buffer (so it cannot filled completely)
|
||||||
|
or buffer size is not a multiple of usb.max_xfer. (so it can clearly detected if the buffer was overflown.)
|
||||||
|
*/
|
||||||
|
|
||||||
printout:
|
printout:
|
||||||
if (verbose > 3)
|
if (verbose > 3)
|
||||||
|
|
6
usbasp.c
6
usbasp.c
|
@ -247,7 +247,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
||||||
functionid & 0xff,
|
functionid & 0xff,
|
||||||
((send[1] << 8) | send[0]) & 0xffff,
|
((send[1] << 8) | send[0]) & 0xffff,
|
||||||
((send[3] << 8) | send[2]) & 0xffff,
|
((send[3] << 8) | send[2]) & 0xffff,
|
||||||
(char *)buffer,
|
buffer,
|
||||||
buffersize & 0xffff,
|
buffersize & 0xffff,
|
||||||
5000);
|
5000);
|
||||||
if(nbytes < 0){
|
if(nbytes < 0){
|
||||||
|
@ -321,7 +321,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
||||||
errorCode = 0;
|
errorCode = 0;
|
||||||
/* now check whether the names match: */
|
/* now check whether the names match: */
|
||||||
/* if vendorName not given ignore it (any vendor matches) */
|
/* if vendorName not given ignore it (any vendor matches) */
|
||||||
r = libusb_get_string_descriptor_ascii(handle, descriptor.iManufacturer & 0xff, string, sizeof(string));
|
r = libusb_get_string_descriptor_ascii(handle, descriptor.iManufacturer & 0xff, (unsigned char*)string, sizeof(string));
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||||
errorCode = USB_ERROR_IO;
|
errorCode = USB_ERROR_IO;
|
||||||
|
@ -335,7 +335,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
||||||
errorCode = USB_ERROR_NOTFOUND;
|
errorCode = USB_ERROR_NOTFOUND;
|
||||||
}
|
}
|
||||||
/* if productName not given ignore it (any product matches) */
|
/* if productName not given ignore it (any product matches) */
|
||||||
r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, string, sizeof(string));
|
r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, (unsigned char*)string, sizeof(string));
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if ((productName != NULL) && (productName[0] != 0)) {
|
if ((productName != NULL) && (productName[0] != 0)) {
|
||||||
errorCode = USB_ERROR_IO;
|
errorCode = USB_ERROR_IO;
|
||||||
|
|
Loading…
Reference in New Issue