From: Ken Taylor Date: Sun, 8 Oct 2023 08:07:05 +0000 (-0700) Subject: openbench-logic-sniffer: Close serial port if device scan fails X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=30b1906315919d1d7e0a9cfdad8c1bfd29edebad;p=libsigrok.git openbench-logic-sniffer: Close serial port if device scan fails --- diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index 09ef0659..b644c923 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -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);