No subject
Thu Jan 15 22:29:28 CST 2009
Modified:
tools/trunk/xpp/astribank_tool.c
tools/trunk/xpp/mpp_funcs.c
Modified: tools/trunk/xpp/astribank_tool.c
URL: http://svn.asterisk.org/svn-view/dahdi/tools/trunk/xpp/astribank_tool.c?view=diff&rev=6617&r1=6616&r2=6617
==============================================================================
--- tools/trunk/xpp/astribank_tool.c (original)
+++ tools/trunk/xpp/astribank_tool.c Wed May 13 15:18:20 2009
@@ -31,6 +31,11 @@
#include "debug.h"
#define DBG_MASK 0x80
+/* if enabled, adds support for resetting pre-MPP USB firmware - if we
+ * failed opening a device and we were asked to reset it, try also the
+ * old protocol.
+ */
+#define SUPPORT_OLD_RESET
static char *progname;
@@ -106,6 +111,36 @@
return 0;
}
+#ifdef SUPPORT_OLD_RESET
+/* Try to reset a device using USB_FW.hex, up to Xorcom rev. 6885 */
+int old_reset(const char* devpath)
+{
+ struct astribank_device *astribank;
+ int ret;
+ struct {
+ uint8_t op;
+ } PACKED header = {0x20}; /* PT_RESET */
+ char *buf = (char*) &header;
+
+ /* Note that the function re-opens the connection to the Astribank
+ * as any reference to the previous connection was lost when mpp_open
+ * returned NULL as the astribank reference. */
+ astribank = astribank_open(devpath, 1);
+ if (!astribank) {
+ DBG("Failed re-opening astribank device for old_reset\n");
+ return -ENODEV;
+ }
+ ret = send_usb(astribank, buf, 1, 5000);
+
+ /* If we just had a reenumeration, we may get -ENODEV */
+ if(ret < 0 && ret != -ENODEV)
+ return ret;
+ /* We don't astribank_close(), as it has likely been
+ * reenumerated by now. */
+ return 0;
+}
+#endif /* SUPPORT_OLD_RESET */
+
int main(int argc, char *argv[])
{
char *devpath = NULL;
@@ -164,6 +199,16 @@
DBG("Startup %s\n", devpath);
if((astribank = mpp_init(devpath)) == NULL) {
ERR("Failed initializing MPP\n");
+#ifdef SUPPORT_OLD_RESET
+ INFO("opt_reset = %s\n", opt_reset);
+ if (opt_reset) {
+ INFO("Trying old reset method\n");
+ if ((ret = old_reset(devpath)) != 0) {
+ ERR("Old reset method failed as well: %d\n", ret);
+ }
+ }
+#endif /* SUPPORT_OLD_RESET */
+
return 1;
}
show_hardware(astribank);
Modified: tools/trunk/xpp/mpp_funcs.c
URL: http://svn.asterisk.org/svn-view/dahdi/tools/trunk/xpp/mpp_funcs.c?view=diff&rev=6617&r1=6616&r2=6617
==============================================================================
--- tools/trunk/xpp/mpp_funcs.c (original)
+++ tools/trunk/xpp/mpp_funcs.c Wed May 13 15:18:20 2009
@@ -928,14 +928,19 @@
ret = mpp_proto_query(astribank);
if(ret < 0) {
ERR("Protocol handshake failed: %d\n", ret);
- return NULL;
+ goto err;
}
ret = mpp_status_query(astribank);
if(ret < 0) {
ERR("Status query failed: %d\n", ret);
- return NULL;
+ goto err;
}
return astribank;
+
+err:
+ if (astribank)
+ astribank_close(astribank, 0);
+ return NULL;
}
void mpp_exit(struct astribank_device *astribank)
More information about the svn-commits
mailing list