how do people feel about this code ?  if you run 'cable probe', urjtag will
walk the USB cable list looking for VID/PID matches.  i dont think any of the
other cables can be probed atm, so i've left them out.

jtag> cable probe
Found USB cable: gnICE+
Connected to libftdi driver.
jtag> detect
IR length: 5
Chain length: 1
Device Id: 00110010011111001000000011001011 (0x327C80CB)
  Manufacturer: Analog Devices (0x0CB)
  Part(0):      BF537 (0x27C8)
  Stepping:     3
  Filename:     /usr/local/share/urjtag/analog/bf537/bf537
-mike

--- a/urjtag/include/urjtag/cable.h
+++ b/urjtag/include/urjtag/cable.h
@@ -227,6 +227,8 @@
 urj_cable_t *urj_tap_cable_usb_connect (urj_chain_t *chain,
                                         const urj_cable_driver_t *driver,
                                         const urj_param_t *params[]);
+int urj_tap_cable_usb_probe (char *params[]);
+
 /**
  * API function to connect to a type-other cable
  *
--- a/urjtag/src/cmd/cmd_cable.c
+++ b/urjtag/src/cmd/cmd_cable.c
@@ -40,6 +40,12 @@
 #include "cmd.h"
 
 static int
+cable_probe (char *params[])
+{
+    return urj_tap_cable_usb_probe (params);
+}
+
+static int
 cmd_cable_run (urj_chain_t *chain, char *params[])
 {
     urj_cable_t *cable = NULL;
@@ -61,6 +67,14 @@ cmd_cable_run (urj_chain_t *chain, char *params[])
         return URJ_STATUS_FAIL;
     }
 
+    if (strcasecmp (params[1], "probe") == 0 && cable_probe (params))
+    {
+        urj_error_set (URJ_ERROR_NOTFOUND,
+                       _("%s: automatic probe found nothing"),
+                       params[0]);
+        return URJ_STATUS_FAIL;
+    }
+
     /* maybe old syntax was used?  search connection type driver */
     for (i = 0; urj_tap_parport_drivers[i]; i++)
         if (strcasecmp (params[1],
--- a/urjtag/src/tap/cable/generic_usbconn.c
+++ b/urjtag/src/tap/cable/generic_usbconn.c
@@ -173,3 +173,33 @@
                "DESC       Some string to match in description or serial no.\n"
                "\n"), cablename);
 }
+
+int
+urj_tap_cable_usb_probe (char *params[])
+{
+    int i,j;
+    urj_usbconn_t *conn;
+
+    urj_log_level_t old_level = urj_log_state.level;
+    urj_log_state.level = URJ_LOG_LEVEL_SILENT;
+
+    for (i = 0; urj_tap_usbconn_drivers[i]; ++i)
+    {
+        for (j = 0; urj_tap_cable_usbconn_cables[j]; ++j)
+        {
+            urj_usbconn_cable_t cable_try = *(urj_tap_cable_usbconn_cables[j]);
+            conn = urj_tap_usbconn_drivers[i]->connect (&cable_try, NULL);
+            if (conn)
+            {
+                urj_log_state.level = old_level;
+                params[1] = (char *)urj_tap_cable_usbconn_cables[j]->name;
+                urj_log (URJ_LOG_LEVEL_NORMAL,
+                         _("Found USB cable: %s\n"), params[1]);
+                return URJ_STATUS_OK;
+            }
+        }
+    }
+
+    urj_log_state.level = old_level;
+    return URJ_STATUS_FAIL;
+}

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
UrJTAG-development mailing list
UrJTAG-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to