]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fluke-dmm/api.c
Get rid of obsolete SR_DI_NUM_PROBES and SR_DI_PROBE_NAMES.
[libsigrok.git] / hardware / fluke-dmm / api.c
index 2d476419307ff79cab7a62691e84930fd1606821..93869a4813d3a07fb7a85d8822f86d251111c05d 100644 (file)
@@ -41,17 +41,23 @@ static const int hwcaps[] = {
        0,
 };
 
-static const char *probe_names[] = {
-       "Probe",
-       NULL,
-};
-
 SR_PRIV struct sr_dev_driver flukedmm_driver_info;
 static struct sr_dev_driver *di = &flukedmm_driver_info;
 
+static char *scan_conn[] = {
+       /* 287/289 */
+       "115200/8n1",
+       /* 187/189 */
+       "9600/8n1",
+       /* Scopemeter 190 series */
+       "1200/8n1",
+       NULL
+};
+
 static const struct flukedmm_profile supported_flukedmm[] = {
-       { FLUKE_187, "187", 100 },
-       { FLUKE_287, "287", 100 },
+       { FLUKE_187, "187", 100, 1000 },
+       { FLUKE_287, "287", 100, 1000 },
+       { FLUKE_190, "199B", 1000, 3500 },
 };
 
 
@@ -81,7 +87,7 @@ static int clear_instances(void)
        return SR_OK;
 }
 
-static int hw_init(void)
+static int hw_init(struct sr_context *sr_ctx)
 {
        struct drv_context *drvc;
 
@@ -90,6 +96,7 @@ static int hw_init(void)
                return SR_ERR_MALLOC;
        }
 
+       drvc->sr_ctx = sr_ctx;
        di->priv = drvc;
 
        return SR_OK;
@@ -109,7 +116,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
        if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
                return NULL;
 
-       if (serial_open(serial, O_RDWR|O_NONBLOCK) != SR_OK)
+       if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
                return NULL;
 
        drvc = di->priv;
@@ -138,10 +145,15 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
 
                /* If CMD_ACK was OK, ID string follows. */
                len = 128;
-               serial_readline(serial, &b, &len, 150);
+               serial_readline(serial, &b, &len, 850);
                if (len < 10)
                        continue;
-               tokens = g_strsplit(buf, ",", 3);
+               if (strcspn(buf, ",") < 15)
+                       /* Looks like it's comma-separated. */
+                       tokens = g_strsplit(buf, ",", 3);
+               else
+                       /* Fluke 199B, at least, uses semicolon. */
+                       tokens = g_strsplit(buf, ";", 3);
                if (!strncmp("FLUKE", tokens[0], 5)
                                && tokens[1] && tokens[2]) {
                        for (i = 0; supported_flukedmm[i].model; i++) {
@@ -169,6 +181,9 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
                        }
                }
                g_strfreev(tokens);
+               if (devices)
+                       /* Found one. */
+                       break;
        }
        serial_close(serial);
        if (!devices)
@@ -181,6 +196,7 @@ static GSList *hw_scan(GSList *options)
 {
        struct sr_hwopt *opt;
        GSList *l, *devices;
+       int i;
        const char *conn, *serialcomm;
 
        conn = serialcomm = NULL;
@@ -202,11 +218,13 @@ static GSList *hw_scan(GSList *options)
                /* Use the provided comm specs. */
                devices = fluke_scan(conn, serialcomm);
        } else {
-               /* Try 115200, as used on 287/289. */
-               devices = fluke_scan(conn, "115200/8n1");
-               if (!devices)
-                       /* Fall back to 9600 for 187/189. */
-                       devices = fluke_scan(conn, "9600/8n1");
+               for (i = 0; scan_conn[i]; i++) {
+                       if ((devices = fluke_scan(conn, scan_conn[i])))
+                               break;
+                       /* The Scopemeter 199B, at least, requires this
+                        * after all the 115k/9.6k confusion. */
+                       g_usleep(5000);
+               }
        }
 
        return devices;
@@ -230,7 +248,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
                return SR_ERR_BUG;
        }
 
-       if (serial_open(devc->serial, O_RDWR|O_NONBLOCK) != SR_OK)
+       if (serial_open(devc->serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
                return SR_ERR;
 
        sdi->status = SR_ST_ACTIVE;
@@ -276,12 +294,6 @@ static int hw_info_get(int info_id, const void **data,
        case SR_DI_HWCAPS:
                *data = hwcaps;
                break;
-       case SR_DI_NUM_PROBES:
-               *data = GINT_TO_POINTER(1);
-               break;
-       case SR_DI_PROBE_NAMES:
-               *data = probe_names;
-               break;
        default:
                return SR_ERR_ARG;
        }