From 760d0a2a75aba6307550bf551c5eb06174c256b5 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 10 Mar 2011 18:48:11 +0000 Subject: xpp: use 'xtalk' for the USB access code * Move most of the USB access code from xpp/ to xpp/xtalk/ . * astribank_tool and such tools can now use a shorter -D mmm/nnn rather than a full path. Signed-off-by: Oron Peled Acked-by: Tzafrir Cohen git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@9825 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/astribank_hexload.c | 51 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'xpp/astribank_hexload.c') diff --git a/xpp/astribank_hexload.c b/xpp/astribank_hexload.c index b268e5d..8362ba2 100644 --- a/xpp/astribank_hexload.c +++ b/xpp/astribank_hexload.c @@ -27,9 +27,9 @@ #include #include #include -#include "debug.h" +#include #include "hexfile.h" -#include "mpp_funcs.h" +#include "mpptalk.h" #include "pic_loader.h" #include "astribank_usb.h" @@ -80,12 +80,16 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile, int ret; int i; char star[] = "+\\+|+/+-"; + const char *devstr; if((hexdata = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) { perror(hexfile); return -errno; } - INFO("Loading hexfile to %s: %s (version %s)\n", + devstr = xusb_devpath(astribank->xusb); + INFO("%s [%s]: Loading %s Firmware: %s (version %s)\n", + devstr, + xusb_serial(astribank->xusb), dev_dest2str(dest), hexdata->fname, hexdata->version_info); #if 0 @@ -96,7 +100,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile, } #endif if((ret = mpp_send_start(astribank, dest, hexdata->version_info)) < 0) { - ERR("Failed hexfile send start: %d\n", ret); + ERR("%s: Failed hexfile send start: %d\n", devstr, ret); return ret; } for(i = 0; i < hexdata->maxlines; i++) { @@ -109,7 +113,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile, fflush(stdout); } if(finished) { - ERR("Extra data after End Of Data Record (line %d)\n", i); + ERR("%s: Extra data after End Of Data Record (line %d)\n", devstr, i); return 0; } if(hexline->d.content.header.tt == TT_EOF) { @@ -118,7 +122,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile, continue; } if((ret = handle_hexline(astribank, hexline)) < 0) { - ERR("Failed hexfile sending in lineno %d (ret=%d)\n", i, ret);; + ERR("%s: Failed hexfile sending in lineno %d (ret=%d)\n", devstr, i, ret);; return ret; } } @@ -127,7 +131,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile, fflush(stdout); } if((ret = mpp_send_end(astribank)) < 0) { - ERR("Failed hexfile send end: %d\n", ret); + ERR("%s: Failed hexfile send end: %d\n", devstr, ret); return ret; } #if 0 @@ -208,21 +212,38 @@ int main(int argc, char *argv[]) ERR("Missing device path.\n"); usage(); } - if((astribank = astribank_open(devpath, iface_num)) == NULL) { - ERR("Opening astribank failed\n"); - return 1; - } - show_astribank_info(astribank); if(opt_dest) { + /* + * MPP Interface + */ + struct astribank_device *astribank; + + if((astribank = mpp_init(devpath, iface_num)) == NULL) { + ERR("%s: Opening astribank failed\n", devpath); + return 1; + } + //show_astribank_info(astribank); if(load_hexfile(astribank, argv[optind], dest) < 0) { - ERR("Loading firmware to %s failed\n", dev_dest2str(dest)); + ERR("%s: Loading firmware to %s failed\n", devpath, dev_dest2str(dest)); return 1; } + astribank_close(astribank, 0); } else if(opt_pic) { - if((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) { - ERR("Loading PIC's failed\n"); + /* + * XPP Interface + */ + struct astribank_device *astribank; + + if((astribank = astribank_open(devpath, iface_num)) == NULL) { + ERR("%s: Opening astribank failed\n", devpath); return 1; } + if (opt_pic) { + if ((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) { + ERR("%s: Loading PIC's failed\n", devpath); + return 1; + } + } } astribank_close(astribank, 0); return 0; -- cgit v1.2.3