Exchange of fprintf(stderr, ...) with avrdude_message(...).

This change was made for the shared library, since library functions
should not write to std-streams directly. Instead avrdude_message()
has to be implemented by the library user. For the avrdude application
this function is implemented in main.c.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1305 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Axel Wachtler
2014-05-18 08:41:46 +00:00
parent 52dd5cc7ac
commit eb5fcb581f
45 changed files with 2380 additions and 2896 deletions

View File

@@ -92,8 +92,7 @@
#ifndef HAVE_PTHREAD_H
static int ft245r_nopthread_open (struct programmer_t *pgm, char * name) {
fprintf(stderr,
"%s: error: no pthread support. Please compile again with pthread installed."
avrdude_message("%s: error: no pthread support. Please compile again with pthread installed."
#if defined(_WIN32)
" See http://sourceware.org/pthreads-win32/."
#endif
@@ -111,9 +110,8 @@ void ft245r_initpgm(PROGRAMMER * pgm) {
#elif defined(DO_NOT_BUILD_FT245R)
static int ft245r_noftdi_open (struct programmer_t *pgm, char * name) {
fprintf(stderr,
"%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
progname);
avrdude_message("%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
progname);
return -1;
}
@@ -170,7 +168,7 @@ static void add_to_buf (unsigned char c) {
else nh = head + 1;
if (nh == tail) {
fprintf (stderr, "buffer overflow. Cannot happen!\n");
avrdude_message("buffer overflow. Cannot happen!\n");
}
buffer[head] = c;
head = nh;
@@ -240,7 +238,7 @@ static int ft245r_chip_erase(PROGRAMMER * pgm, AVRPART * p) {
unsigned char res[4];
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
@@ -266,12 +264,12 @@ static int ft245r_set_bitclock(PROGRAMMER * pgm) {
}
if ((verbose>1) || FT245R_DEBUG) {
fprintf(stderr," ft245r: spi bitclk %d -> ft baudrate %d\n",
avrdude_message(" ft245r: spi bitclk %d -> ft baudrate %d\n",
rate / 2, rate);
}
r = ftdi_set_baudrate(handle, rate);
if (r) {
fprintf(stderr, "Set baudrate (%d) failed with error '%s'.\n",
avrdude_message("Set baudrate (%d) failed with error '%s'.\n",
rate, ftdi_get_error_string (handle));
return -1;
}
@@ -378,8 +376,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
int i;
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
fprintf(stderr,
"%s: AVR_OP_PGM_ENABLE command not defined for %s\n", progname, p->desc);
avrdude_message("%s: AVR_OP_PGM_ENABLE command not defined for %s\n",
progname, p->desc);
fflush(stderr);
return -1;
}
@@ -392,8 +390,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
if (res[p->pollindex-1] == p->pollvalue) return 0;
if ((verbose>=1) || FT245R_DEBUG) {
fprintf(stderr,
"%s: Program enable command not successful. Retrying.\n", progname);
avrdude_message("%s: Program enable command not successful. Retrying.\n",
progname);
fflush(stderr);
}
set_pin(pgm, PIN_AVR_RESET, ON);
@@ -406,8 +404,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
}
}
fprintf(stderr,
"%s: Device is not responding to program enable. Check connection.\n", progname);
avrdude_message("%s: Device is not responding to program enable. Check connection.\n",
progname);
fflush(stderr);
return -1;
@@ -546,9 +544,8 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
}
}
if (devnum < 0) {
fprintf(stderr,
"%s: invalid portname '%s': use 'ft[0-9]+'\n",
progname,port);
avrdude_message("%s: invalid portname '%s': use 'ft[0-9]+'\n",
progname,port);
return -1;
}
} else {
@@ -562,8 +559,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
fprintf(stderr,
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USB_DEVICE_FT245;
@@ -575,7 +571,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
pgm->usbsn[0]?pgm->usbsn:NULL,
devnum);
if (rv) {
fprintf (stderr, "can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
avrdude_message("can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
goto cleanup_no_usb;
}
@@ -605,9 +601,8 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang
if (rv) {
fprintf(stderr,
"%s: Synchronous BitBangMode is not supported (%s)\n",
progname, ftdi_get_error_string(handle));
avrdude_message("%s: Synchronous BitBangMode is not supported (%s)\n",
progname, ftdi_get_error_string(handle));
goto cleanup;
}
@@ -660,7 +655,7 @@ static void ft245r_close(PROGRAMMER * pgm) {
}
static void ft245r_display(PROGRAMMER * pgm, const char * p) {
fprintf(stderr, "%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
avrdude_message("%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS);
}
@@ -713,7 +708,7 @@ static void put_request(int addr, int bytes, int n) {
} else {
p = malloc(sizeof(struct ft245r_request));
if (!p) {
fprintf(stderr, "can't alloc memory\n");
avrdude_message("can't alloc memory\n");
exit(1);
}
}
@@ -807,7 +802,7 @@ static int ft245r_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
put_request(addr_save, buf_pos, 0);
//ft245r_sync(pgm);
#if 0
fprintf(stderr, "send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n",
avrdude_message("send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n",
addr_save,buf_pos,
extract_data_out(pgm, buf , (0*4 + 3) ),
extract_data_out(pgm, buf , (1*4 + 3) ),