]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi_serial.c
scpi_serial: Add support for (broken) devices sending NL+CR terminator.
[libsigrok.git] / src / scpi / scpi_serial.c
index 8690d6f146485ab65b7cc2a737b17708e101f1b7..6f642211f264609eb3bf3cdcc79779af1cae8432 100644 (file)
@@ -35,6 +35,7 @@ struct scpi_serial {
        gboolean got_newline;
 };
 
+/* Default serial port options for some known USB devices */
 static const struct {
        uint16_t vendor_id;
        uint16_t product_id;
@@ -42,7 +43,9 @@ static const struct {
 } scpi_serial_usb_ids[] = {
        { 0x0403, 0xed72, "115200/8n1/flow=1" }, /* Hameg HO720 */
        { 0x0403, 0xed73, "115200/8n1/flow=1" }, /* Hameg HO730 */
-       { 0x0aad, 0x0118, "115200/8n1" },        /* R&S HMO1002 */
+       { 0x0aad, 0x0117, "115200/8n1" },        /* R&S HMO series, previously branded as Hameg HMO */
+       { 0x0aad, 0x0118, "115200/8n1" },        /* R&S HMO series, previously branded as Hameg HMO */
+       { 0x0aad, 0x0119, "115200/8n1" },        /* R&S HMO series, previously branded as Hameg HMO */
 };
 
 static GSList *scpi_serial_scan(struct drv_context *drvc)
@@ -111,9 +114,6 @@ static int scpi_serial_open(struct sr_scpi_dev_inst *scpi)
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return SR_ERR;
 
-       if (serial_flush(serial) != SR_OK)
-               return SR_ERR;
-
        sscpi->got_newline = FALSE;
 
        return SR_OK;
@@ -187,7 +187,12 @@ static int scpi_serial_read_data(void *priv, char *buf, int maxlen)
        if (ret > 0) {
                if (buf[ret - 1] == '\n') {
                        sscpi->got_newline = TRUE;
-                       sr_spew("Received terminator");
+                       sr_spew("Received NL terminator");
+               } else if (ret > 1 &&
+                          buf[ret - 2] == '\n' && buf[ret - 1] == '\r') {
+                       sscpi->got_newline = TRUE;
+                       sr_spew("Received NL+CR terminator");
+                       ret--;
                } else {
                        sscpi->got_newline = FALSE;
                }