return scpi->receive(scpi->priv, scpi_response);
}
+/**
+ * Read part of a response from SCPI device.
+ *
+ * @param scpi Previously initialised SCPI device structure.
+ * @param buf Buffer to store result.
+ * @param maxlen Maximum number of bytes to read.
+ *
+ * @return Number of bytes read, or SR_ERR upon failure.
+ */
+SR_PRIV int sr_scpi_read(struct sr_scpi_dev_inst *scpi,
+ char *buf, int maxlen)
+{
+ return scpi->read(scpi->priv, buf, maxlen);
+}
+
/**
* Close SCPI device.
*
scpi->source_remove = scpi_serial_source_remove;
scpi->send = scpi_serial_send;
scpi->receive = scpi_serial_receive;
+ scpi->read = serial_read;
scpi->close = serial_close;
scpi->free = sr_serial_dev_inst_free;
scpi->priv = serial;
return SR_OK;
}
+SR_PRIV int scpi_usbtmc_read(void *priv, unsigned 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;
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->priv = usbtmc;
int (*source_remove)(void *priv);
int (*send)(void *priv, const char *command);
int (*receive)(void *priv, char **scpi_response);
+ int (*read)(void *priv, char *buf, int maxlen);
int (*close)(void *priv);
void (*free)(void *priv);
void *priv;
const char *command);
SR_PRIV int sr_scpi_receive(struct sr_scpi_dev_inst *scpi,
char **scpi_response);
+SR_PRIV int sr_scpi_read(struct sr_scpi_dev_inst *scpi, char *buf, int maxlen);
SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi);
SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi);