Can be used to send raw data on a SCPI connection.
Signed-off-by: Sven Schnelle <redacted>
int (*send)(void *priv, const char *command);
int (*read_begin)(void *priv);
int (*read_data)(void *priv, char *buf, int maxlen);
+ int (*write_data)(void *priv, char *buf, int len);
int (*read_complete)(void *priv);
int (*close)(struct sr_scpi_dev_inst *scpi);
void (*free)(void *priv);
const char *format, va_list args);
SR_PRIV int sr_scpi_read_begin(struct sr_scpi_dev_inst *scpi);
SR_PRIV int sr_scpi_read_data(struct sr_scpi_dev_inst *scpi, char *buf, int maxlen);
+SR_PRIV int sr_scpi_write_data(struct sr_scpi_dev_inst *scpi, char *buf, int len);
SR_PRIV int sr_scpi_read_complete(struct sr_scpi_dev_inst *scpi);
SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi);
SR_PRIV void sr_scpi_free(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.
*
return len;
}
+static int scpi_tcp_raw_write_data(void *priv, char *buf, int len)
+{
+ struct scpi_tcp *tcp = priv;
+ int sentlen;
+
+ sentlen = send(tcp->socket, buf, len, 0);
+
+ if (sentlen < 0) {
+ sr_err("Send error: %s.", g_strerror(errno));
+ return SR_ERR;
+ }
+
+ return sentlen;
+}
+
static int scpi_tcp_rigol_read_data(void *priv, char *buf, int maxlen)
{
struct scpi_tcp *tcp = priv;
.send = scpi_tcp_send,
.read_begin = scpi_tcp_read_begin,
.read_data = scpi_tcp_raw_read_data,
+ .write_data = scpi_tcp_raw_write_data,
.read_complete = scpi_tcp_read_complete,
.close = scpi_tcp_close,
.free = scpi_tcp_free,