#include "serial.h"
#include "srec.h"
#include <time.h>
+#include "gdb_assert.h"
+#include "gdb_string.h"
extern void report_transfer_performance (unsigned long, time_t, time_t);
srec[reclen] = '\0';
puts_debug ("sent -->", srec, "<--");
}
- SERIAL_WRITE (desc, srec, reclen);
+ serial_write (desc, srec, reclen);
for (s = abfd->sections; s; s = s->next)
if (s->flags & SEC_LOAD)
acknowledgement is sent back. */
do
{
- SERIAL_WRITE (desc, srec, reclen);
+ serial_write (desc, srec, reclen);
if (ui_load_progress_hook)
if (ui_load_progress_hook (section_name, (unsigned long) i))
error ("Canceled the download");
puts_debug ("sent -->", srec, "<--");
}
- SERIAL_WRITE (desc, srec, reclen);
+ serial_write (desc, srec, reclen);
/* Some monitors need these to wake up properly. (Which ones? -sts) */
- SERIAL_WRITE (desc, "\r\r", 2);
+ serial_write (desc, "\r\r", 2);
if (remote_debug)
puts_debug ("sent -->", "\r\r", "<---");
- SERIAL_FLUSH_INPUT (desc);
+ serial_flush_input (desc);
report_transfer_performance (data_count, start_time, end_time);
}
const static char data_code_table[] = "123";
const static char term_code_table[] = "987";
const static char header_code_table[] = "000";
- const static char *formats[] =
- {"S%c%02X%04X",
- "S%c%02X%06X",
- "S%c%02X%08X"};
char const *code_table;
int addr_size;
int payload_size;
payload_size = 0; /* Term or header packets have no payload */
/* Output the header. */
-
- sprintf (srec, formats[addr_size - 2], code_table[addr_size - 2],
- addr_size + payload_size + 1, (int) targ_addr);
+ snprintf (srec, (*maxrecsize) + 1, "S%c%02X%0*X",
+ code_table[addr_size - 2],
+ addr_size + payload_size + 1,
+ addr_size * 2, (int) targ_addr);
/* Note that the checksum is calculated on the raw data, not the
hexified data. It includes the length, address and the data
+ ((targ_addr >> 16) & 0xff)
+ ((targ_addr >> 24) & 0xff));
+ /* NOTE: cagney/2003-08-10: The equation is old. Check that the
+ recent snprintf changes match that equation. */
+ gdb_assert (strlen (srec) == 1 + 1 + 2 + addr_size * 2);
p = srec + 1 + 1 + 2 + addr_size * 2;
/* Build the Srecord. */