X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fscpi_serial.c;h=9711c010a80fb9f5c92cfe60af7710d5e8760684;hb=c1bcb8cc633cc69ce4a872f59ec2b686bc00bd04;hp=052d6c1efe618f059e162cc750635e55e94bbfe1;hpb=d87c1766f2968d121cea9d913b06dc3493adfd9e;p=libsigrok.git diff --git a/hardware/common/scpi_serial.c b/hardware/common/scpi_serial.c index 052d6c1e..9711c010 100644 --- a/hardware/common/scpi_serial.c +++ b/hardware/common/scpi_serial.c @@ -105,60 +105,6 @@ static int scpi_serial_send(void *priv, const char *command) return SR_OK; } -static int scpi_serial_receive(void *priv, char **scpi_response) -{ - int len, ret; - char buf[256]; - unsigned int i; - GString *response; - struct scpi_serial *sscpi = priv; - struct sr_serial_dev_inst *serial = sscpi->serial; - - response = g_string_sized_new(1024); - - for (i = 0; i <= SCPI_READ_RETRIES; i++) { - while ((len = serial_read(serial, buf, sizeof(buf))) > 0) - response = g_string_append_len(response, buf, len); - - if (response->len > 0 && - response->str[response->len-1] == '\n') { - sr_spew("Fetched full SCPI response."); - break; - } - - g_usleep(SCPI_READ_RETRY_TIMEOUT); - } - - if (response->len == 0) { - sr_dbg("No SCPI response received."); - g_string_free(response, TRUE); - *scpi_response = NULL; - return SR_ERR; - } else if (response->str[response->len - 1] == '\n') { - /* - * The SCPI response contains a LF ('\n') at the end and we - * don't need this so replace it with a '\0' and decrement - * the length. - */ - response->str[--response->len] = '\0'; - ret = SR_OK; - } else { - sr_warn("Incomplete SCPI response received!"); - ret = SR_ERR; - } - - /* Minor optimization: steal the string instead of copying. */ - *scpi_response = response->str; - - /* A SCPI response can be quite large, print at most 50 characters. */ - sr_dbg("SCPI response received (length %d): '%.50s'", - response->len, response->str); - - g_string_free(response, FALSE); - - return ret; -} - static int scpi_serial_read_begin(void *priv) { struct scpi_serial *sscpi = priv;