X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fscpi%2Fscpi.c;h=5b36daab0dc2bcd1cb943eef3db22864899f655a;hb=11e3a56380a660b07a34150dcadda7723c0f65f9;hp=00f4ef805eb45843dfaf502942235c040b7f0bc2;hpb=815685462fdab21a390b5aecc253b92753439f06;p=libsigrok.git diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index 00f4ef80..5b36daab 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -337,6 +337,21 @@ SR_PRIV int sr_scpi_read_data(struct sr_scpi_dev_inst *scpi, return scpi->read_data(scpi->priv, buf, maxlen); } +/** + * Send data to SCPI device. + * + * @param scpi Previously initialised SCPI device structure. + * @param buf Buffer with data to send. + * @param len Number of bytes to send. + * + * @return Number of bytes read, or SR_ERR upon failure. + */ +SR_PRIV int sr_scpi_write_data(struct sr_scpi_dev_inst *scpi, + char *buf, int maxlen) +{ + return scpi->write_data(scpi->priv, buf, maxlen); +} + /** * Check whether a complete SCPI response has been received. * @@ -612,7 +627,7 @@ SR_PRIV int sr_scpi_get_double(struct sr_scpi_dev_inst *scpi, if (ret != SR_OK && !response) return ret; - if (sr_atod(response, scpi_response) == SR_OK) + if (sr_atod_ascii(response, scpi_response) == SR_OK) ret = SR_OK; else ret = SR_ERR_DATA; @@ -636,6 +651,7 @@ SR_PRIV int sr_scpi_get_opc(struct sr_scpi_dev_inst *scpi) gboolean opc; for (i = 0; i < SCPI_READ_RETRIES; i++) { + opc = FALSE; sr_scpi_get_bool(scpi, SCPI_CMD_OPC, &opc); if (opc) return SR_OK; @@ -893,6 +909,7 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi, char *response; gchar **tokens; struct sr_scpi_hw_info *hw_info; + gchar *idn_substr; response = NULL; tokens = NULL; @@ -921,7 +938,13 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi, g_free(response); hw_info = g_malloc0(sizeof(struct sr_scpi_hw_info)); - hw_info->manufacturer = g_strstrip(g_strdup(tokens[0])); + + idn_substr = g_strstr_len(tokens[0], -1, "IDN "); + if (idn_substr == NULL) + hw_info->manufacturer = g_strstrip(g_strdup(tokens[0])); + else + hw_info->manufacturer = g_strstrip(g_strdup(idn_substr + 4)); + hw_info->model = g_strstrip(g_strdup(tokens[1])); hw_info->serial_number = g_strstrip(g_strdup(tokens[2])); hw_info->firmware_version = g_strstrip(g_strdup(tokens[3]));