+ struct sr_dev_inst *sdi;
+ struct dev_context *devc;
+ struct sr_config *src;
+ struct sr_serial_dev_inst *serial;
+ struct sr_channel_group *cg;
+ struct sr_channel *ch;
+ GSList *l;
+ int ret, len;
+ const char *conn, *serialcomm;
+ char buf[100];
+ char *bufptr;
+ double version;
+
+ conn = serialcomm = NULL;
+ for (l = options; l; l = l->next) {
+ src = l->data;
+ switch (src->key) {
+ case SR_CONF_CONN:
+ conn = g_variant_get_string(src->data, NULL);
+ break;
+ case SR_CONF_SERIALCOMM:
+ serialcomm = g_variant_get_string(src->data, NULL);
+ break;
+ }
+ }
+ if (!conn)
+ return NULL;
+ if (!serialcomm)
+ serialcomm = SERIALCOMM;
+
+ serial = sr_serial_dev_inst_new(conn, serialcomm);
+
+ if (serial_open(serial, SERIAL_RDWR) != SR_OK)
+ return NULL;
+
+ serial_flush(serial);
+
+ /*
+ * First stop potentially running monitoring and wait for 50ms before
+ * next command can be sent.
+ */
+ if (serial_write_blocking(serial, CMD_MONITOR_STOP,
+ strlen(CMD_MONITOR_STOP), serial_timeout(serial,
+ strlen(CMD_MONITOR_STOP))) < (int)strlen(CMD_MONITOR_STOP)) {
+ sr_dbg("Unable to write while probing for hardware.");
+ serial_close(serial);
+ return NULL;
+ }
+ g_usleep(50 * 1000);
+
+ if (serial_write_blocking(serial, CMD_VERSION,
+ strlen(CMD_VERSION), serial_timeout(serial,
+ strlen(CMD_VERSION))) < (int)strlen(CMD_VERSION)) {
+ sr_dbg("Unable to write while probing for hardware.");
+ serial_close(serial);
+ return NULL;
+ }