]> sigrok.org Git - libsigrok.git/commitdiff
openbench-logic-sniffer: Close serial port if device scan fails
authorKen Taylor <redacted>
Sun, 8 Oct 2023 08:07:05 +0000 (01:07 -0700)
committerSoeren Apel <redacted>
Mon, 19 Aug 2024 20:53:03 +0000 (22:53 +0200)
src/hardware/openbench-logic-sniffer/api.c

index 09ef065939c22e6511775c1bc3f25fa62ea6bd3a..b644c9232193cfc9731a7a3096976b6f29fa7196 100644 (file)
@@ -150,6 +150,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        g_usleep(RESPONSE_DELAY_US);
 
        if (serial_has_receive_data(serial) == 0) {
+               serial_close(serial);
                sr_dbg("Didn't get any ID reply.");
                return NULL;
        }
@@ -157,11 +158,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        num_read =
                serial_read_blocking(serial, buf, 4, serial_timeout(serial, 4));
        if (num_read < 0) {
+               serial_close(serial);
                sr_err("Getting ID reply failed (%d).", num_read);
                return NULL;
        }
 
        if (strncmp(buf, "1SLO", 4) && strncmp(buf, "1ALS", 4)) {
+               serial_close(serial);
                GString *id = sr_hexdump_new((uint8_t *)buf, num_read);
 
                sr_err("Invalid ID reply (got %s).", id->str);