X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fscpi.c;h=29a24dd2ec61f645f597073295500026da991ba2;hb=9d156555a557aa079056d42fbc9ddd12338e842e;hp=8093490886d8eace63ece67a5ddbde6f4d880db8;hpb=613c11084915ac24de9bd0355a7479ece9adfa35;p=libsigrok.git diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index 80934908..29a24dd2 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -312,9 +312,15 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi, g_string_append_len(response, buf, len); } + /* Get rid of trailing linefeed if present */ + if (response->len >= 1 && response->str[response->len - 1] == '\n') + g_string_truncate(response, response->len - 1); + *scpi_response = response->str; g_string_free(response, FALSE); + sr_spew("Got response: '%s'.", *scpi_response); + return SR_OK; } @@ -404,7 +410,7 @@ SR_PRIV int sr_scpi_get_float(struct sr_scpi_dev_inst *scpi, if (!response) return SR_ERR; - if (sr_atof(response, scpi_response) == SR_OK) + if (sr_atof_ascii(response, scpi_response) == SR_OK) ret = SR_OK; else ret = SR_ERR; @@ -505,7 +511,7 @@ SR_PRIV int sr_scpi_get_floatv(struct sr_scpi_dev_inst *scpi, response_array = g_array_sized_new(TRUE, FALSE, sizeof(float), 256); while (*ptr) { - if (sr_atof(*ptr, &tmp) == SR_OK) + if (sr_atof_ascii(*ptr, &tmp) == SR_OK) response_array = g_array_append_val(response_array, tmp); else @@ -600,7 +606,6 @@ 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; @@ -613,10 +618,6 @@ 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