8 int hexfile_parse(
char *line,
unsigned int *type,
unsigned int *addr,
unsigned char *buffer)
10 unsigned int row_len = 0;
11 unsigned int row_index = 7;
18 retval = sscanf(line,
":%2x%4x%2x", &row_len, addr, type);
22 cksum += *addr & 0xFF;
31 if (sscanf(&line[row_index],
"%2x", &tmp) == 1)
34 buffer[i++] = (
unsigned char) tmp;
39 if (sscanf(&line[row_index],
"%2x", &tmp) == 1)
41 if ((cksum + (uint8_t) tmp) == 0)
return row_len;
47 int hexfile_out(
char *line,
unsigned int type,
unsigned int address,
unsigned char *data,
unsigned int bytes)
53 sprintf(line,
":%2.2X%4.4X%2.2X", bytes, address, type);
55 cksum -= address >> 8;
56 cksum -= address & 0xFF;
59 for (i=0; i<bytes; i++)
61 sprintf(tmp,
"%2.2X", data[i]);
65 sprintf(tmp,
"%2.2X\r\n", cksum);