From: Martin Ling Date: Sun, 29 Dec 2013 12:13:04 +0000 (+0100) Subject: scpi: Strip trailing newline from *IDN response if present. X-Git-Tag: libsigrok-0.3.0~373 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bc7b7eb196b7e3f15bed857ee8b3533c0d899b3f;p=libsigrok.git scpi: Strip trailing newline from *IDN response if present. --- diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index 7329b294..b2eb4ced 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -552,6 +552,7 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi, { int num_tokens; char *response; + char *newline; gchar **tokens; struct sr_scpi_hw_info *hw_info; @@ -564,6 +565,10 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi, sr_info("Got IDN string: '%s'", response); + /* Remove trailing newline if present. */ + if ((newline = g_strrstr(response, "\n"))) + newline[0] = '\0'; + /* * The response to a '*IDN?' is specified by the SCPI spec. It contains * a comma-separated list containing the manufacturer name, instrument