scpi_tcp: split into scpi_tcp_raw and scpi_tcp_rigol
The current implementation is renamed to tcp-rigol as it seems to be a Rigol proprietary protocol used only on Rigol VS5000 series. A new tcp-raw implementation is introduced which simply carries raw SCPI commands over TCP. It is probably a much more common protocol and it is at least available on Rigol DS2000 series on port 5555.
This commit is contained in:
parent
f754c14691
commit
104ed12553
|
@ -66,12 +66,14 @@ static int parse_strict_bool(const char *str, gboolean *ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV extern const struct sr_scpi_dev_inst scpi_serial_dev;
|
SR_PRIV extern const struct sr_scpi_dev_inst scpi_serial_dev;
|
||||||
SR_PRIV extern const struct sr_scpi_dev_inst scpi_tcp_dev;
|
SR_PRIV extern const struct sr_scpi_dev_inst scpi_tcp_raw_dev;
|
||||||
|
SR_PRIV extern const struct sr_scpi_dev_inst scpi_tcp_rigol_dev;
|
||||||
SR_PRIV extern const struct sr_scpi_dev_inst scpi_usbtmc_dev;
|
SR_PRIV extern const struct sr_scpi_dev_inst scpi_usbtmc_dev;
|
||||||
SR_PRIV extern const struct sr_scpi_dev_inst scpi_vxi_dev;
|
SR_PRIV extern const struct sr_scpi_dev_inst scpi_vxi_dev;
|
||||||
|
|
||||||
static const struct sr_scpi_dev_inst *scpi_devs[] = {
|
static const struct sr_scpi_dev_inst *scpi_devs[] = {
|
||||||
&scpi_tcp_dev,
|
&scpi_tcp_raw_dev,
|
||||||
|
&scpi_tcp_rigol_dev,
|
||||||
&scpi_usbtmc_dev,
|
&scpi_usbtmc_dev,
|
||||||
#ifdef HAVE_RPC
|
#ifdef HAVE_RPC
|
||||||
&scpi_vxi_dev,
|
&scpi_vxi_dev,
|
||||||
|
|
|
@ -165,7 +165,26 @@ SR_PRIV int scpi_tcp_read_begin(void *priv)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int scpi_tcp_read_data(void *priv, char *buf, int maxlen)
|
SR_PRIV int scpi_tcp_raw_read_data(void *priv, char *buf, int maxlen)
|
||||||
|
{
|
||||||
|
struct scpi_tcp *tcp = priv;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = recv(tcp->socket, buf, maxlen, 0);
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
sr_err("Receive error: %s", strerror(errno));
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcp->length_bytes_read = LENGTH_BYTES;
|
||||||
|
tcp->response_length = len < maxlen ? len : maxlen + 1;
|
||||||
|
tcp->response_bytes_read = len;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
SR_PRIV int scpi_tcp_rigol_read_data(void *priv, char *buf, int maxlen)
|
||||||
{
|
{
|
||||||
struct scpi_tcp *tcp = priv;
|
struct scpi_tcp *tcp = priv;
|
||||||
int len;
|
int len;
|
||||||
|
@ -227,9 +246,9 @@ SR_PRIV void scpi_tcp_free(void *priv)
|
||||||
g_free(tcp->port);
|
g_free(tcp->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV const struct sr_scpi_dev_inst scpi_tcp_dev = {
|
SR_PRIV const struct sr_scpi_dev_inst scpi_tcp_raw_dev = {
|
||||||
.name = "TCP",
|
.name = "RAW TCP",
|
||||||
.prefix = "tcp",
|
.prefix = "tcp-raw",
|
||||||
.priv_size = sizeof(struct scpi_tcp),
|
.priv_size = sizeof(struct scpi_tcp),
|
||||||
.dev_inst_new = scpi_tcp_dev_inst_new,
|
.dev_inst_new = scpi_tcp_dev_inst_new,
|
||||||
.open = scpi_tcp_open,
|
.open = scpi_tcp_open,
|
||||||
|
@ -237,7 +256,23 @@ SR_PRIV const struct sr_scpi_dev_inst scpi_tcp_dev = {
|
||||||
.source_remove = scpi_tcp_source_remove,
|
.source_remove = scpi_tcp_source_remove,
|
||||||
.send = scpi_tcp_send,
|
.send = scpi_tcp_send,
|
||||||
.read_begin = scpi_tcp_read_begin,
|
.read_begin = scpi_tcp_read_begin,
|
||||||
.read_data = scpi_tcp_read_data,
|
.read_data = scpi_tcp_raw_read_data,
|
||||||
|
.read_complete = scpi_tcp_read_complete,
|
||||||
|
.close = scpi_tcp_close,
|
||||||
|
.free = scpi_tcp_free,
|
||||||
|
};
|
||||||
|
|
||||||
|
SR_PRIV const struct sr_scpi_dev_inst scpi_tcp_rigol_dev = {
|
||||||
|
.name = "RIGOL TCP",
|
||||||
|
.prefix = "tcp-rigol",
|
||||||
|
.priv_size = sizeof(struct scpi_tcp),
|
||||||
|
.dev_inst_new = scpi_tcp_dev_inst_new,
|
||||||
|
.open = scpi_tcp_open,
|
||||||
|
.source_add = scpi_tcp_source_add,
|
||||||
|
.source_remove = scpi_tcp_source_remove,
|
||||||
|
.send = scpi_tcp_send,
|
||||||
|
.read_begin = scpi_tcp_read_begin,
|
||||||
|
.read_data = scpi_tcp_rigol_read_data,
|
||||||
.read_complete = scpi_tcp_read_complete,
|
.read_complete = scpi_tcp_read_complete,
|
||||||
.close = scpi_tcp_close,
|
.close = scpi_tcp_close,
|
||||||
.free = scpi_tcp_free,
|
.free = scpi_tcp_free,
|
||||||
|
|
Loading…
Reference in New Issue