]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi_visa.c
scpi: Rephrase buffer resize for free space during SCPI read, add comments
[libsigrok.git] / src / scpi / scpi_visa.c
index fee25ba1cf7689027f5ac54287dc5815a0df81fa..a8f50e4f65c71fde5451d19032e80a78e610d0e8 100644 (file)
@@ -51,9 +51,9 @@ static int scpi_visa_dev_inst_new(void *priv, struct drv_context *drvc,
        return SR_OK;
 }
 
-static int scpi_visa_open(void *priv)
+static int scpi_visa_open(struct sr_scpi_dev_inst *scpi)
 {
-       struct scpi_visa *vscpi = priv;
+       struct scpi_visa *vscpi = scpi->priv;
 
        if (viOpenDefaultRM(&vscpi->rmgr) != VI_SUCCESS) {
                sr_err("Cannot open default resource manager.");
@@ -87,21 +87,16 @@ static int scpi_visa_source_remove(struct sr_session *session, void *priv)
 static int scpi_visa_send(void *priv, const char *command)
 {
        struct scpi_visa *vscpi = priv;
-       gchar *terminated_command;
        ViUInt32 written = 0;
        int len;
 
-       terminated_command = g_strconcat(command, "\n", NULL);
-       len = strlen(terminated_command);
-       if (viWrite(vscpi->vi, (ViBuf) (terminated_command + written), len,
+       len = strlen(command);
+       if (viWrite(vscpi->vi, (ViBuf) (command + written), len,
                        &written) != VI_SUCCESS) {
                sr_err("Error while sending SCPI command: '%s'.", command);
-               g_free(terminated_command);
                return SR_ERR;
        }
 
-       g_free(terminated_command);
-
        sr_spew("Successfully sent SCPI command: '%s'.", command);
 
        return SR_OK;
@@ -140,9 +135,9 @@ static int scpi_visa_read_complete(void *priv)
        return !(status & 16);
 }
 
-static int scpi_visa_close(void *priv)
+static int scpi_visa_close(struct sr_scpi_dev_inst *scpi)
 {
-       struct scpi_visa *vscpi = priv;
+       struct scpi_visa *vscpi = scpi->priv;
 
        viClose(vscpi->vi);
        viClose(vscpi->rmgr);