]> sigrok.org Git - libsigrok.git/blobdiff - hardware/common/scpi_usbtmc.c
scpi_tcp: must define _WIN32_WINNT to 0x0501 or higher to get getaddrinfo().
[libsigrok.git] / hardware / common / scpi_usbtmc.c
index e4c10be67a0cf2e5592ad6f1f5aa5aeeed473dbc..9648722c20415c125de663461c95a1d421daea5e 100644 (file)
@@ -111,6 +111,21 @@ SR_PRIV int scpi_usbtmc_receive(void *priv, char **scpi_response)
        return SR_OK;
 }
 
+SR_PRIV int scpi_usbtmc_read(void *priv, char *buf, int maxlen)
+{
+       struct sr_usbtmc_dev_inst *usbtmc = priv;
+       int len;
+
+       len = read(usbtmc->fd, buf, maxlen);
+
+       if (len < 0) {
+               sr_err("Read error: %s", strerror(errno));
+               return SR_ERR;
+       }
+
+       return len;
+}
+
 SR_PRIV int scpi_usbtmc_close(void *priv)
 {
        struct sr_usbtmc_dev_inst *usbtmc = priv;
@@ -121,6 +136,11 @@ SR_PRIV int scpi_usbtmc_close(void *priv)
        return SR_OK;
 }
 
+static void scpi_usbtmc_free(void *priv)
+{
+       return sr_usbtmc_dev_inst_free(priv);
+}
+
 SR_PRIV struct sr_scpi_dev_inst *scpi_usbtmc_dev_inst_new(const char *device)
 {
        struct sr_scpi_dev_inst *scpi;
@@ -139,8 +159,9 @@ SR_PRIV struct sr_scpi_dev_inst *scpi_usbtmc_dev_inst_new(const char *device)
        scpi->source_remove = scpi_usbtmc_source_remove;
        scpi->send = scpi_usbtmc_send;
        scpi->receive = scpi_usbtmc_receive;
+       scpi->read = scpi_usbtmc_read;
        scpi->close = scpi_usbtmc_close;
-       scpi->free = sr_usbtmc_dev_inst_free;
+       scpi->free = scpi_usbtmc_free;
        scpi->priv = usbtmc;
 
        return scpi;