From: Timo Kokkonen Date: Tue, 2 Jun 2020 06:56:03 +0000 (-0700) Subject: scpi_serial: Add support for (broken) devices sending NL+CR terminator. X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=a0ade2f933d62fee3dea55475c7a9c69883b8b25;hp=d7df9dc738b22dd4e5083fb818ad1dbaf186f13e scpi_serial: Add support for (broken) devices sending NL+CR terminator. This allows SCPI code to work with devices that terminate their responses with NL+CR (instead of usual NL) like some GW-Instek DMMs. --- diff --git a/src/scpi/scpi_serial.c b/src/scpi/scpi_serial.c index 6158f089..6f642211 100644 --- a/src/scpi/scpi_serial.c +++ b/src/scpi/scpi_serial.c @@ -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; }