]> sigrok.org Git - libsigrok.git/blobdiff - hardware/common/scpi.c
demo: Cast to double while calculating the pattern frequency.
[libsigrok.git] / hardware / common / scpi.c
index 8093490886d8eace63ece67a5ddbde6f4d880db8..29a24dd2ec61f645f597073295500026da991ba2 100644 (file)
@@ -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