+ /* If CMD_ACK was OK, ID string follows. */
+ len = 128;
+ serial_readline(serial, &b, &len, 150);
+ if (len < 10)
+ continue;
+ tokens = g_strsplit(buf, ",", 3);
+ if (!strncmp("FLUKE", tokens[0], 5)
+ && tokens[1] && tokens[2]) {
+ for (i = 0; supported_flukedmm[i].model; i++) {
+ if (strcmp(supported_flukedmm[i].modelname, tokens[0] + 6))
+ continue;
+ /* Skip leading spaces in version number. */
+ for (s = 0; tokens[1][s] == ' '; s++);
+ if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "Fluke",
+ tokens[0] + 6, tokens[1] + s)))
+ return NULL;
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ sr_err("Device context malloc failed.");
+ return NULL;
+ }
+ devc->profile = &supported_flukedmm[i];
+ devc->serial = serial;
+ sdi->priv = devc;
+ sdi->driver = di;
+ if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ return NULL;
+ sdi->probes = g_slist_append(sdi->probes, probe);
+ drvc->instances = g_slist_append(drvc->instances, sdi);
+ devices = g_slist_append(devices, sdi);
+ break;
+ }
+ }
+ g_strfreev(tokens);
+ }
+ serial_close(serial);
+ if (!devices)
+ sr_serial_dev_inst_free(serial);
+
+ return devices;
+}
+
+static GSList *hw_scan(GSList *options)
+{
+ struct sr_hwopt *opt;
+ GSList *l, *devices;
+ const char *conn, *serialcomm;
+
+ conn = serialcomm = NULL;
+ for (l = options; l; l = l->next) {
+ opt = l->data;
+ switch (opt->hwopt) {
+ case SR_HWOPT_CONN:
+ conn = opt->value;
+ break;
+ case SR_HWOPT_SERIALCOMM:
+ serialcomm = opt->value;
+ break;
+ }
+ }
+ if (!conn)
+ return NULL;
+
+ if (serialcomm) {
+ /* 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");
+ }