diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-02-28 01:23:19 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-02-28 01:23:19 +0000 |
commit | ff8823199f375d709a689dd017950d575b649df6 (patch) | |
tree | 7244e80bb45da5f27b747c8bc9aee36b984dd5cd /xpp/utils/hexfile.c | |
parent | 121cb4b570046fe612938d1eb401181c970b4636 (diff) |
Merge xpp rev. 3495:
------------------------------------------------------------------------
r2243 | tzafrir | 2007-02-28 02:05:59 +0200 (Wed, 28 Feb 2007) | 4 lines
* xpp rev. 3495: fix a race in the FXO driver of recent weeks.
* Add the Astribank BRI driver (though still needs bristuffed zaptel
to build and thus will not build by default)
------------------------------------------------------------------------
r2239 | tzafrir | 2007-02-27 08:14:18 +0200 (Tue, 27 Feb 2007) | 18 lines
Xorcom rev. 3491:
* Version of xpp modules is set from xpp/.version, rather than "unknown".
* Astribank devices are now initialized in parallel: faster startup
when there are multiple Astribanks.
* Re-added support for the old format of /proc/xpp/sync write:
(echo N 0 > /proc/xpp/sync ) . The new format (SYNC=NN) is preffered.
* Firmware update to fix a PCM issue.
* Fixed a build issue with kernel 2.6.8 .
* Fixed missing initialization in Zaptel::Xpp::Xbus .
* genzaptelconf will now set FXS ports as LS by default. To set them as
KS, use fxs_default_start=ks in /etc/default/zaptel / /etc/sysconfig/zaptel
(Also a workaround for #7755 ).
* Groundwork for sync from zaptel master span: if zaptel is built with
ZAPTEL_SYNC_TIC (see zaptel/team/tzafrir/sync ), xpp will report its
drift from the zaptel sync master.
* USB firmware update: had bad lines checksums (and fxload did not report).
* fpga_load can now better report bad hex file checksum ;-) .
------------------------------------------------------------------------
r2223 | tzafrir | 2007-02-24 03:05:05 +0200 (Sat, 24 Feb 2007) | 3 lines
Add the Zaptel and Zaptel::Xpp perl modules, and some simple
utilities that use them. disabled by default for now.
------------------------------------------------------------------------
r2222 | tzafrir | 2007-02-24 02:55:05 +0200 (Sat, 24 Feb 2007) | 2 lines
Make the xpp/utils/Makefile in 1.2 closer to the one in 1.4 .
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2247 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/hexfile.c')
-rw-r--r-- | xpp/utils/hexfile.c | 73 |
1 files changed, 49 insertions, 24 deletions
diff --git a/xpp/utils/hexfile.c b/xpp/utils/hexfile.c index f6e4149..a4b12c5 100644 --- a/xpp/utils/hexfile.c +++ b/xpp/utils/hexfile.c @@ -57,6 +57,38 @@ int checksum(struct hexline *hexline) return chksm & 0xFF; } +int dump_hexline(int recordno, struct hexline *line, FILE *outfile) +{ + uint8_t ll; + uint16_t offset; + uint8_t tt; + uint8_t old_chksum; + uint8_t new_chksum; + uint8_t *data; + unsigned int i; + + ll = line->d.content.header.ll; + offset = line->d.content.header.offset; + tt = line->d.content.header.tt; + fprintf(outfile, ":%02X%04X%02X", ll, offset, tt); + data = line->d.content.tt_data.data; + for(i = 0; i < ll; i++) { + fprintf(outfile, "%02X", data[i]); + } + old_chksum = data[ll]; + data[ll] = 0; + new_chksum = 0xFF - checksum(line) + 1; + data[ll] = old_chksum; + fprintf(outfile, "%02X\n", new_chksum); + if(new_chksum != old_chksum) { + if(report_func) + report_func(LOG_ERR, "record #%d: new_chksum(%02X) != old_chksum(%02X)\n", + recordno, new_chksum, old_chksum); + return 0; + } + return 1; +} + static int update_hexline(struct hexdata *hexdata, char *buf) { int ret; @@ -142,8 +174,10 @@ static int update_hexline(struct hexdata *hexdata, char *buf) } hexline->d.content.header.ll--; /* Fix the checksum */ if(checksum(hexline) != 0) { - if(report_func) - report_func(LOG_ERR, "Bad checksum\n"); + if(report_func) { + report_func(LOG_ERR, "Bad checksum (%d instead of 0)\n", checksum(hexline)); + dump_hexline(last_line, hexline, stderr); + } return -EINVAL; } if(hexdata->got_eof) @@ -166,14 +200,7 @@ void free_hexdata(struct hexdata *hexdata) int dump_hexfile(struct hexdata *hexdata, FILE *outfile) { - uint8_t ll; - uint16_t offset; - uint8_t tt; - uint8_t old_chksum; - uint8_t new_chksum; - uint8_t *data; unsigned int i; - unsigned int j; for(i = 0; i <= hexdata->last_line; i++) { struct hexline *line = hexdata->lines[i]; @@ -182,20 +209,8 @@ int dump_hexfile(struct hexdata *hexdata, FILE *outfile) report_func(LOG_ERR, "Missing line at #%d\n", i); return -EINVAL; } - ll = line->d.content.header.ll; - offset = line->d.content.header.offset; - tt = line->d.content.header.tt; - fprintf(outfile, ":%02X%04X%02X", ll, offset, tt); - data = line->d.content.tt_data.data; - for(j = 0; j < ll; j++) { - fprintf(outfile, "%02X", data[j]); - } - old_chksum = data[ll]; - data[ll] = 0; - new_chksum = 0xFF - checksum(line) + 1; - data[ll] = old_chksum; - assert(new_chksum == old_chksum); - fprintf(outfile, "%02X\n", new_chksum); + if(!dump_hexline(i, line, outfile)) + return -EINVAL; } return 0; } @@ -299,8 +314,18 @@ struct hexdata *parse_hexfile(const char *fname, unsigned int maxlines) } chomp(buf); if(buf[0] == '#') { + char *dollar_start; + char *dollar_end; + if(report_func) - report_func(LOG_INFO, "Comment '%s'\n", buf + 1); + report_func(LOG_INFO, "Comment: %s\n", buf + 1); + /* Search for RCS keywords */ + if((dollar_start = strchr(buf, '$')) == NULL) + continue; + if((dollar_end = strchr(dollar_start + 1, '$')) == NULL) + continue; + *(dollar_end + 1) = '\0'; + strncpy(hexdata->version_info, dollar_start, BUFSIZ - 1); continue; } if(buf[0] != ':') { |