X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frigol-ds%2Fprotocol.c;h=77af43e94d3d3af4f7bdc93a693dd9f781d03c61;hb=90230cfa7f7ae62b21169fa2156f54e2902e7ad1;hp=d9d8dc7ea1d79f51352d813146b58f9971840b95;hpb=9ea62f2e0ac1ae9ee01215148177ae4e6f344078;p=libsigrok.git diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c index d9d8dc7e..77af43e9 100644 --- a/src/hardware/rigol-ds/protocol.c +++ b/src/hardware/rigol-ds/protocol.c @@ -221,7 +221,7 @@ static int rigol_ds_check_stop(const struct sr_dev_inst *sdi) return SR_OK; if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", - ch->index + 1) != SR_OK) + ch->index + 1) != SR_OK) return SR_ERR; /* Check that the number of samples will be accepted */ if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK) @@ -432,7 +432,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi) break; case PROTOCOL_V3: if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", - ch->index + 1) != SR_OK) + ch->index + 1) != SR_OK) return SR_ERR; if (devc->data_source != DATA_SOURCE_LIVE) { if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK) @@ -672,7 +672,9 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) else for (i = 0; i < len; i++) devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + float vdivlog = log10f(vdiv); + int digits = -(int)vdivlog + (vdivlog < 0.0); + sr_analog_init(&analog, &encoding, &meaning, &spec, digits); analog.meaning->channels = g_slist_append(NULL, ch); analog.num_samples = len; analog.data = devc->data; @@ -769,6 +771,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi) { struct dev_context *devc; + struct sr_channel *ch; char *cmd; unsigned int i; int res; @@ -782,6 +785,8 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi) g_free(cmd); if (res != SR_OK) return SR_ERR; + ch = g_slist_nth_data(sdi->channels, i); + ch->enabled = devc->analog_channels[i]; } sr_dbg("Current analog channel state:"); for (i = 0; i < devc->model->analog_channels; i++) @@ -804,6 +809,8 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi) g_free(cmd); if (res != SR_OK) return SR_ERR; + ch = g_slist_nth_data(sdi->channels, i + devc->model->analog_channels); + ch->enabled = devc->digital_channels[i]; sr_dbg("D%d: %s", i, devc->digital_channels[i] ? "on" : "off"); } }