diff options
Diffstat (limited to 'xpp/utils')
-rw-r--r-- | xpp/utils/Makefile | 8 | ||||
-rw-r--r-- | xpp/utils/fpga_load.c | 71 | ||||
-rwxr-xr-x | xpp/utils/genzaptelconf | 28 | ||||
-rw-r--r-- | xpp/utils/hexfile.c | 73 | ||||
-rw-r--r-- | xpp/utils/hexfile.h | 1 | ||||
-rw-r--r-- | xpp/utils/test_parse.c | 1 | ||||
-rw-r--r-- | xpp/utils/xpp_fxloader | 2 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Xpp/Xbus.pm | 1 |
8 files changed, 115 insertions, 70 deletions
diff --git a/xpp/utils/Makefile b/xpp/utils/Makefile index c25379a..e902cbd 100644 --- a/xpp/utils/Makefile +++ b/xpp/utils/Makefile @@ -32,7 +32,7 @@ WCTDM=$(ZAPTEL_DIR)/wctdm.c CFLAGS = -g -Wall $(EXTRA_CFLAGS) %.8: % - pod2man $^ > $@ || $(RM) $@ + pod2man --section 8 $^ > $@ || $(RM) $@ PERL_SCRIPTS = zt_registration xpp_sync lszaptel PERL_MANS = zt_registration.8 xpp_sync.8 lszaptel.8 @@ -53,7 +53,11 @@ all: $(TARGETS) docs: $(PERL_MANS) -install: all +# give an ugly warning if Timer::Hires is missing: +sanity_checks: + perl -c ../calibrate_slics >/dev/null || true + +install: all sanity_checks $(INSTALL) -d $(DESTDIR)$(SBINDIR) $(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(SBINDIR)/ $(INSTALL) -d $(DESTDIR)$(DATADIR) diff --git a/xpp/utils/fpga_load.c b/xpp/utils/fpga_load.c index 426e6a6..2c03704 100644 --- a/xpp/utils/fpga_load.c +++ b/xpp/utils/fpga_load.c @@ -10,8 +10,21 @@ static const char rcsid[] = "$Id$"; -#define ERR(fmt, arg...) fprintf(stderr, "%s: ERROR: " fmt, progname, ## arg) -#define INFO(fmt, arg...) fprintf(stderr, "%s: " fmt, progname, ## arg) +#define ERR(fmt, arg...) do { \ + if(verbose >= LOG_ERR) \ + fprintf(stderr, "%s: ERROR: " fmt, \ + progname, ## arg); \ + } while(0); +#define INFO(fmt, arg...) do { \ + if(verbose >= LOG_INFO) \ + fprintf(stderr, "%s: " fmt, \ + progname, ## arg); \ + } while(0); +#define DBG(fmt, arg...) do { \ + if(verbose >= LOG_DEBUG) \ + fprintf(stderr, "%s: DBG: " fmt, \ + progname, ## arg); \ + } while(0); static int verbose = LOG_WARNING; static char *progname; @@ -229,14 +242,13 @@ int eeprom_set(struct my_usb_device *mydev, const struct myeeprom *eeprom) char buf[PACKET_SIZE]; struct fpga_packet_header *phead = (struct fpga_packet_header *)buf; - if(verbose >= LOG_DEBUG) - INFO("%s Start...\n", __FUNCTION__); + DBG("%s Start...\n", __FUNCTION__); assert(mydev != NULL); phead->header.op = EEPROM_SET; memcpy(&phead->d.eeprom_set.data, eeprom, EEPROM_SIZE); len = sizeof(phead->d.eeprom_set) + sizeof(phead->header.op); if(verbose >= LOG_DEBUG) { - INFO("%s write %d bytes\n", __FUNCTION__, len); + DBG("%s write %d bytes\n", __FUNCTION__, len); dump_packet((char *)phead, len); } ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); @@ -262,7 +274,7 @@ int eeprom_set(struct my_usb_device *mydev, const struct myeeprom *eeprom) return -EINVAL; } if(verbose >= LOG_DEBUG) { - INFO("%s read %d bytes\n", __FUNCTION__, ret); + DBG("%s read %d bytes\n", __FUNCTION__, ret); dump_packet(buf, ret); } return 0; @@ -279,12 +291,11 @@ int eeprom_get(struct my_usb_device *mydev) assert(mydev != NULL); eeprom = &mydev->eeprom; - if(verbose >= LOG_DEBUG) - INFO("%s Start...\n", __FUNCTION__); + DBG("%s Start...\n", __FUNCTION__); phead->header.op = EEPROM_GET; len = sizeof(phead->header.op); /* warning: sending small packet */ if(verbose >= LOG_DEBUG) { - INFO("%s write %d bytes\n", __FUNCTION__, len); + DBG("%s write %d bytes\n", __FUNCTION__, len); dump_packet(buf, len); } ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); @@ -310,7 +321,7 @@ int eeprom_get(struct my_usb_device *mydev) return -EINVAL; } if(verbose >= LOG_DEBUG) { - INFO("%s read %d bytes\n", __FUNCTION__, ret); + DBG("%s read %d bytes\n", __FUNCTION__, ret); dump_packet(buf, ret); } memcpy(eeprom, &phead->d.eeprom_get.data, EEPROM_SIZE); @@ -339,8 +350,7 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) phead->d.data_packet.reserved = 0x00; memcpy(phead->d.data_packet.data, data, len); len += sizeof(hexline->d.content.header); - if(verbose >= LOG_DEBUG) - INFO("%04d+\r", seq); + DBG("%04d+\r", seq); ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); if(ret < 0) { ERR("bulk_write failed: %s\n", usb_strerror()); @@ -357,8 +367,7 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) return ret; } else if(ret == 0) return 0; - if(verbose >= LOG_INFO) - INFO("%04d-\r", seq); + DBG("%04d-\r", seq); phead = (struct fpga_packet_header *)buf; if(phead->header.op != STATUS_REPLY) { ERR("Got unexpected reply op=%d\n", phead->header.op); @@ -372,13 +381,11 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) case FW_FAIL_RESET: case FW_FAIL_TRANS: ERR("status reply %s (%d)\n", load_status2str(status), status); - if(verbose >= LOG_INFO) - dump_packet(buf, ret); + dump_packet(buf, ret); return -EPROTO; default: ERR("Unknown status reply %d\n", status); - if(verbose >= LOG_INFO) - dump_packet(buf, ret); + dump_packet(buf, ret); return -EPROTO; } return 0; @@ -468,9 +475,11 @@ int my_usb_device_init(const char devpath[], struct my_usb_device *mydev) config_desc = mydev->dev->config; interface = config_desc->interface; iface_desc = interface->altsetting; - if(verbose >= LOG_INFO) - INFO("Vendor:Product=%04X:%04X Class=%d (endpoints=%d)\n", - dev_desc->idVendor, dev_desc->idProduct, dev_desc->bDeviceClass, iface_desc->bNumEndpoints); + INFO("Vendor:Product=%04X:%04X Class=%d (endpoints=%d)\n", + dev_desc->idVendor, + dev_desc->idProduct, + dev_desc->bDeviceClass, + iface_desc->bNumEndpoints); if(iface_desc->bInterfaceClass != 0xFF) { ERR("Wrong Interface class %d\n", iface_desc->bInterfaceClass); return 0; @@ -518,8 +527,7 @@ int renumerate_device(struct my_usb_device *mydev) int ret; assert(mydev != NULL); - if(verbose >= LOG_INFO) - INFO("Renumerating\n"); + DBG("Renumerating\n"); phead->header.op = RENUMERATE; ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, 1, TIMEOUT); if(ret < 0) { @@ -541,10 +549,11 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) unsigned int j = 0; int ret; int finished = 0; + const char *v = hexdata->version_info; + v = (v[0]) ? v : "Unknown"; assert(mydev != NULL); - if(verbose >= LOG_INFO) - INFO("Start...\n"); + INFO("FPGA_LOAD (version %s)\n", v); /* * i - is the line number * j - is the sequence number, on USB 2, i=j, but on @@ -561,8 +570,7 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) return 0; } if(hexline->d.content.header.tt == TT_EOF) { - if(verbose >= LOG_INFO) - INFO("End of data\n"); + DBG("End of data\n"); finished = 1; continue; } @@ -579,8 +587,7 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) j += ret; } } - if(verbose >= LOG_INFO) - INFO("Finished...\n"); + DBG("Finished...\n"); return 1; } @@ -731,8 +738,7 @@ int main(int argc, char *argv[]) if(vendor || product || release || serial || source ) opt_read_eeprom = opt_write_eeprom = 1; #endif - if(verbose >= LOG_INFO) - INFO("Startup %s\n", devpath); + DBG("Startup %s\n", devpath); if(!my_usb_device_init(devpath, &mydev)) { ERR("Failed to initialize USB device '%s'\n", devpath); @@ -792,8 +798,7 @@ int main(int argc, char *argv[]) show_device_info(&mydev); } #endif - if(verbose >= LOG_INFO) - INFO("Exiting\n"); + DBG("Exiting\n"); dev_err: my_usb_device_cleanup(&mydev); return ret; diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf index a5fb0b0..c5dedd4 100755 --- a/xpp/utils/genzaptelconf +++ b/xpp/utils/genzaptelconf @@ -37,6 +37,9 @@ VERSION=0.5.8 rcsid='$Id$' lc_country=us +# set to: ls, ks or gs for (Loopstart, Kewlstart and GroundStart) +# on FXS channels (FXO signalling). +fxs_default_start=ls base_exten=6000 # If set: no context changes are made in zapata-channels.conf #context_manual=yes @@ -267,17 +270,22 @@ print_pattern() { local chan=$1 local sig=$2 #fxs/fxo local mode=$3 - local method='ks' - - # Coutries in which we need to use busydetect: - # United Arab Emirats, Israel, Slovenia - case "$lc_country" in - ae|il|si) - if [ "$sig" = 'fxs' ]; then + local method + + if [ "$sig" = 'fxs' ]; then + # Coutries in which we need to use busydetect: + # United Arab Emirats, Israel, Slovenia + case "$lc_country" in + ae|il|si) method=ls - fi - ;; - esac + ;; + *) + method=ks + ;; + esac + else + method="$fxs_default_start" + fi case "$mode" in list) case "$sig" in 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] != ':') { diff --git a/xpp/utils/hexfile.h b/xpp/utils/hexfile.h index c7f5df0..4c6e689 100644 --- a/xpp/utils/hexfile.h +++ b/xpp/utils/hexfile.h @@ -101,6 +101,7 @@ struct hexdata { unsigned int maxlines; unsigned int last_line; int got_eof; + char version_info[BUFSIZ]; struct hexline *lines[ZERO_SIZE]; }; diff --git a/xpp/utils/test_parse.c b/xpp/utils/test_parse.c index bdcdea7..c98ca83 100644 --- a/xpp/utils/test_parse.c +++ b/xpp/utils/test_parse.c @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Parsing failed\n"); return 1; } + fprintf(stderr, "=== %s === (version: %s)\n", argv[i], hd->version_info); dump_hexfile2(hd, stdout, 60 ); free_hexdata(hd); } diff --git a/xpp/utils/xpp_fxloader b/xpp/utils/xpp_fxloader index 918a712..3d200e8 100644 --- a/xpp/utils/xpp_fxloader +++ b/xpp/utils/xpp_fxloader @@ -136,7 +136,7 @@ load_fpga() { card_ver=`$FPGA_LOAD -g -D $dev | sed -n 's/^.*Release: *//'` firm_ver=`hexfile_version $FIRMWARE_DIR/$fw` - $LOGGER "FPGA Firmware $FIRMWARE_DIR/$fw into $dev" + $LOGGER "FPGA Firmware $FIRMWARE_DIR/$fw (version: $firm_ver) into $dev" sleep_if_race $FPGA_LOAD -D "$dev" -I "$FIRMWARE_DIR/$fw" 2>&1 >/dev/null | $LOGGER status=$PIPESTATUS diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm index 0f27d76..8d9d340 100644 --- a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm +++ b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm @@ -33,6 +33,7 @@ sub new($$) { bless $self, $pack; $self->{NAME} or die "Missing xbus name"; my $prefix = "$proc_base/" . $self->{NAME}; + @{$self->{XPDS}} = (); foreach my $fqn (glob "$prefix/XPD-??") { $fqn =~ s:$proc_base/::; $fqn =~ /(\d+)$/; |