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.
*
/**
* Free SCPI device.
*
- * @param scpi Previously initialized SCPI device structure.
- *
- * @return SR_OK on success, SR_ERR on failure.
+ * @param scpi Previously initialized SCPI device structure. If NULL,
+ * this function does nothing.
*/
SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi)
{
+ if (!scpi)
+ return;
+
scpi->free(scpi->priv);
g_free(scpi->priv);
g_free(scpi);
char *response;
gchar **tokens;
struct sr_scpi_hw_info *hw_info;
+ gchar *idn_substr;
response = NULL;
tokens = NULL;
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]));