- struct sr_device_instance *sdi;
- struct ols_device *ols;
- GSList *ports, *l;
- GPollFD *fds, probefd;
- int devcnt, final_devcnt, num_ports, fd, ret, i;
- char buf[8], **device_names, **serial_params;
-
- if (deviceinfo)
- ports = g_slist_append(NULL, strdup(deviceinfo));
- else
- /* No specific device given, so scan all serial ports. */
- ports = list_serial_ports();
-
- num_ports = g_slist_length(ports);
- fds = calloc(1, num_ports * sizeof(GPollFD));
- device_names = malloc(num_ports * sizeof(char *));
- serial_params = malloc(num_ports * sizeof(char *));
- devcnt = 0;
- for (l = ports; l; l = l->next) {
- /* The discovery procedure is like this: first send the Reset
- * command (0x00) 5 times, since the device could be anywhere
- * in a 5-byte command. Then send the ID command (0x02).
- * If the device responds with 4 bytes ("OLS1" or "SLA1"), we
- * have a match.
- *
- * Since it may take the device a while to respond at 115Kb/s,
- * we do all the sending first, then wait for all of them to
- * respond with g_poll().
- */
- sr_info("ols: probing %s...", (char *)l->data);
- fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
- if (fd != -1) {
- serial_params[devcnt] = serial_backup_params(fd);
- serial_set_params(fd, 115200, 8, 0, 1, 2);
- ret = SR_OK;
- for (i = 0; i < 5; i++) {
- if ((ret = send_shortcommand(fd,
- CMD_RESET)) != SR_OK) {
- /* Serial port is not writable. */
- break;
- }
- }
- if (ret != SR_OK) {
- serial_restore_params(fd,
- serial_params[devcnt]);
- serial_close(fd);
- continue;
- }
- send_shortcommand(fd, CMD_ID);
- fds[devcnt].fd = fd;
- fds[devcnt].events = G_IO_IN;
- device_names[devcnt] = strdup(l->data);
- devcnt++;
+ struct sr_hwopt *opt;
+ struct sr_dev_inst *sdi;
+ struct drv_context *drvc;
+ struct dev_context *devc;
+ struct sr_probe *probe;
+ struct sr_serial_dev_inst *serial;
+ GPollFD probefd;
+ GSList *l, *devices;
+ int ret, i;
+ const char *conn, *serialcomm;
+ char buf[8];
+
+ (void)options;
+ drvc = odi->priv;
+ devices = NULL;
+
+ 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;