Hi,
reading analog data from an HMO1024 (Firmware 04.527) with sigrok-cli
failed because the frame limit could not be set.
The patch below sets SR_CONF_GET | SR_CONF_SET for frame limit and fixes
a double free issue in hmo_receive_data.
With those changes I got incomplete data because the USB transfer takes
longer than the scpi->read_timeout_ms of 1 second that is defined in
scpi.c/scpi_dev_inst_new. Therefore I reset the timeout in
scpi.c/sr_scpi_get_string whenever the device sends a partial response -
not sure whether this is acceptable in all circumstances.
with kind regards,
Mathias
diff --git a/src/hardware/hameg-hmo/protocol.c
b/src/hardware/hameg-hmo/protocol.c
index 8f39ba1..7299946 100644
--- a/src/hardware/hameg-hmo/protocol.c
+++ b/src/hardware/hameg-hmo/protocol.c
@@ -47,7 +47,7 @@ static const char *hameg_scpi_dialect[] = {
static const uint32_t hmo_devopts[] = {
SR_CONF_OSCILLOSCOPE,
- SR_CONF_LIMIT_FRAMES,
+ SR_CONF_LIMIT_FRAMES| SR_CONF_GET | SR_CONF_SET,
SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_NUM_TIMEBASE | SR_CONF_GET,
@@ -672,6 +672,8 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void
*cb_data)
(void)fd;
+ data = NULL;
+
if (!(sdi = cb_data))
return TRUE;
@@ -704,6 +706,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void
*cb_data)
sr_session_send(cb_data, &packet);
g_slist_free(analog.channels);
g_array_free(data, TRUE);
+ data = NULL;
break;
case SR_CHANNEL_LOGIC:
if (sr_scpi_get_uint8v(sdi->conn, NULL, &data) !=
SR_OK) {
@@ -722,6 +725,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void
*cb_data)
packet.payload = &logic;
sr_session_send(cb_data, &packet);
g_array_free(data, TRUE);
+ data = NULL;
break;
default:
sr_err("Invalid channel type.");
diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c
index 7604411..19e7f12 100644
--- a/src/scpi/scpi.c
+++ b/src/scpi/scpi.c
@@ -383,7 +383,7 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst
*scpi,
char buf[256];
int len;
GString *response;
- gint64 start;
+ gint64 laststart;
unsigned int elapsed_ms;
if (command)
@@ -393,20 +393,24 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst
*scpi,
if (sr_scpi_read_begin(scpi) != SR_OK)
return SR_ERR;
- start = g_get_monotonic_time();
+ laststart = g_get_monotonic_time();
response = g_string_new("");
*scpi_response = NULL;
-
while (!sr_scpi_read_complete(scpi)) {
len = sr_scpi_read_data(scpi, buf, sizeof(buf));
if (len < 0) {
+ sr_err("Incompletely read SCPI response.");
g_string_free(response, TRUE);
return SR_ERR;
}
+ else if ( len > 0 )
+ {
+ laststart = g_get_monotonic_time();
+ }
g_string_append_len(response, buf, len);
- elapsed_ms = (g_get_monotonic_time() - start) / 1000;
+ elapsed_ms = (g_get_monotonic_time() - laststart) / 1000;
if (elapsed_ms >= scpi->read_timeout_ms)
{
sr_err("Timed out waiting for SCPI response.");
@@ -426,7 +430,7 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst
*scpi,
*scpi_response = response->str;
g_string_free(response, FALSE);
- sr_spew("Got response: '%.70s'.", *scpi_response);
+ sr_spew("Got response: '%.70s', length %d", *scpi_response,
strlen(*scpi_response) );
return SR_OK;
}
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel