X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_tcp.c;h=e87f5e784fb1d0ab61b0eaac8f44b06091b04076;hb=ffa5f177f15dd8c75612d65b20459e7cdccc68b9;hp=14a2d2cb7b3a226fbfd2bd7778bdc3ac3eb99df6;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git diff --git a/src/scpi/scpi_tcp.c b/src/scpi/scpi_tcp.c index 14a2d2cb..e87f5e78 100644 --- a/src/scpi/scpi_tcp.c +++ b/src/scpi/scpi_tcp.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #ifdef _WIN32 #define _WIN32_WINNT 0x0501 #include @@ -71,9 +72,9 @@ static int scpi_tcp_dev_inst_new(void *priv, struct drv_context *drvc, return SR_OK; } -static int scpi_tcp_open(void *priv) +static int scpi_tcp_open(struct sr_scpi_dev_inst *scpi) { - struct scpi_tcp *tcp = priv; + struct scpi_tcp *tcp = scpi->priv; struct addrinfo hints; struct addrinfo *results, *res; int err; @@ -134,12 +135,9 @@ static int scpi_tcp_send(void *priv, const char *command) { struct scpi_tcp *tcp = priv; int len, out; - char *terminated_command; - terminated_command = g_strdup_printf("%s\r\n", command); - len = strlen(terminated_command); - out = send(tcp->socket, terminated_command, len, 0); - g_free(terminated_command); + len = strlen(command); + out = send(tcp->socket, command, len, 0); if (out < 0) { sr_err("Send error: %s", g_strerror(errno)); @@ -229,9 +227,9 @@ static int scpi_tcp_read_complete(void *priv) tcp->response_bytes_read >= tcp->response_length); } -static int scpi_tcp_close(void *priv) +static int scpi_tcp_close(struct sr_scpi_dev_inst *scpi) { - struct scpi_tcp *tcp = priv; + struct scpi_tcp *tcp = scpi->priv; if (close(tcp->socket) < 0) return SR_ERR;