+ /* We'll try the discovery sequence three times in case the device
+ * is not in an idle state when we send ID. */
+ while (!devices && retry < 3) {
+ retry++;
+ serial_flush(fd);
+ if (serial_write(fd, "ID\r", 3) == -1) {
+ sr_err("fluke-dmm: unable to send ID string: %s",
+ strerror(errno));
+ continue;
+ }
+
+ /* Response is first a CMD_ACK byte (ASCII '0' for OK,
+ * or '1' to signify an error. */
+ len = 128;
+ serial_readline(fd, &b, &len, 150);
+ if (len != 1)
+ continue;
+ if (buf[0] != '0')
+ continue;
+
+ /* If CMD_ACK was OK, ID string follows. */
+ len = 128;
+ serial_readline(fd, &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_dbg("fluke-dmm: failed to malloc devc");
+ return NULL;
+ }
+ devc->profile = &supported_flukedmm[i];
+ devc->serial = sr_serial_dev_inst_new(conn, -1);
+ devc->serialcomm = g_strdup(serialcomm);
+ 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(fd);
+
+ return devices;
+}
+
+static GSList *hw_scan(GSList *options)
+{
+ struct sr_hwopt *opt;
+ GSList *l, *devices;
+ const char *conn, *serialcomm;
+