+ snprintf(req, sizeof(req), "%s\r\n",
+ nmadmm_requests[NMADMM_REQ_IDN].req_str);
+ for (cnt = 0; cnt < 7; cnt++) {
+ if (serial_write(serial, req, strlen(req)) == -1) {
+ sr_err("Unable to send identification request: %d %s.",
+ errno, strerror(errno));
+ return NULL;
+ }
+ len = BUF_MAX;
+ serial_readline(serial, &buf, &len, 1500);
+ if (!len)
+ continue;
+ buf[BUF_MAX - 1] = '\0';
+
+ /* Match ID string, e.g. "1834 065 V1.06,IF V1.02" (DM950) */
+ if (g_regex_match_simple("^1834 [^,]*,IF V*", (char *)buf, 0, 0)) {
+ auxtype = xgittoint(buf[7]);
+ // TODO: Will this work with non-DM950?
+ snprintf(fmttype, sizeof(fmttype), "DM9%d0", auxtype);
+ sr_spew("Norma %s DMM %s detected!", fmttype, &buf[9]);
+
+ if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
+ "Norma", fmttype, buf + 9)))
+ return NULL;
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ sr_err("Device context malloc failed.");
+ return NULL;
+ }
+ devc->type = auxtype;
+ devc->version = g_strdup(&buf[9]);
+ devc->elapsed_msec = g_timer_new();
+
+ sdi->conn = serial;
+ sdi->priv = devc;
+ sdi->driver = di;
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE,
+ "P1")))
+ return NULL;
+ sdi->channels = g_slist_append(sdi->channels, ch);
+ drvc->instances = g_slist_append(drvc->instances, sdi);
+ devices = g_slist_append(devices, sdi);
+ break;
+ }
+
+ /*
+ * The interface of the DM9x0 contains a cap that needs to
+ * charge for up to 10s before the interface works, if not
+ * powered externally. Therefore wait a little to improve
+ * chances.
+ */
+ if (cnt == 3) {
+ sr_info("Waiting 5s to allow interface to settle.");
+ g_usleep(5 * 1000 * 1000);
+ }
+ }