- 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] = g_strdup(l->data);
- devcnt++;
+ /* 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.
+ */
+ sr_info("ols: probing %s .", conn);
+ if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
+ return NULL;
+
+ ret = SR_OK;
+ for (i = 0; i < 5; i++) {
+ if ((ret = send_shortcommand(serial, CMD_RESET)) != SR_OK) {
+ sr_err("ols: port %s is not writable.", conn);
+ break;