From: Uwe Hermann Date: Sun, 28 Aug 2016 21:52:48 +0000 (+0200) Subject: Have remaining drivers default to digits=2 for analog values. X-Git-Tag: libsigrok-0.5.0~233 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7dcaddd3f0df3a87dae252eb1f64f7b0e3997b8f;p=libsigrok.git Have remaining drivers default to digits=2 for analog values. The default so far was 0, which meant there would be no significant digits at all, yielding results that looked strange/wrong to the user. Long-term all remaining drivers should be fixed to use the actual, correct digits and spec_digits values according to the device's capabilities and/or datasheet/manual. Until that is done, a default of digits=2 is used as a temporary workaround. This fixes the remaining parts of bug #815. --- diff --git a/src/hardware/brymen-dmm/protocol.c b/src/hardware/brymen-dmm/protocol.c index 4cd61ad6..5a7f2252 100644 --- a/src/hardware/brymen-dmm/protocol.c +++ b/src/hardware/brymen-dmm/protocol.c @@ -32,7 +32,8 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi) devc = sdi->priv; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); analog.num_samples = 1; analog.meaning->mq = 0; diff --git a/src/hardware/fluke-dmm/fluke.c b/src/hardware/fluke-dmm/fluke.c index 1aa9637f..094832dd 100644 --- a/src/hardware/fluke-dmm/fluke.c +++ b/src/hardware/fluke-dmm/fluke.c @@ -63,7 +63,8 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi, e++; analog = g_malloc0(sizeof(struct sr_datafeed_analog)); - sr_analog_init(analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(analog, &encoding, &meaning, &spec, 2); analog->data = g_malloc(sizeof(float)); analog->meaning->channels = sdi->channels; analog->num_samples = 1; @@ -176,7 +177,8 @@ static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi, } analog = g_malloc0(sizeof(struct sr_datafeed_analog)); - sr_analog_init(analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(analog, &encoding, &meaning, &spec, 2); analog->data = g_malloc(sizeof(float)); analog->meaning->channels = sdi->channels; analog->num_samples = 1; @@ -401,7 +403,8 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens) fvalue = 1.0; } - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); analog.meaning->channels = sdi->channels; analog.num_samples = 1; analog.data = &fvalue; diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 029edbd7..2681a8f0 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -764,7 +764,8 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) encoding.is_signed = TRUE; encoding.is_float = TRUE; encoding.is_bigendian = FALSE; - encoding.digits = 0; + /* TODO: Use proper 'digits' value for this device (and its modes). */ + encoding.digits = 2; encoding.is_digits_decimal = FALSE; encoding.scale.p = 1; encoding.scale.q = 1; @@ -779,7 +780,8 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) } meaning.mqflags = 0; meaning.channels = g_slist_append(NULL, ch); - spec.spec_digits = 0; + /* TODO: Use proper 'digits' value for this device (and its modes). */ + spec.spec_digits = 2; packet.payload = &analog; sr_session_send(sdi, &packet); g_slist_free(meaning.channels); diff --git a/src/hardware/norma-dmm/protocol.c b/src/hardware/norma-dmm/protocol.c index fcaae133..96a47379 100644 --- a/src/hardware/norma-dmm/protocol.c +++ b/src/hardware/norma-dmm/protocol.c @@ -123,7 +123,8 @@ static void nma_process_line(const struct sr_dev_inst *sdi) /* Start decoding. */ value = 0.0; scale = 1.0; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); /* * The numbers are hex digits, starting from 0. diff --git a/src/hardware/testo/protocol.c b/src/hardware/testo/protocol.c index eb02f9f8..396612fd 100644 --- a/src/hardware/testo/protocol.c +++ b/src/hardware/testo/protocol.c @@ -246,7 +246,8 @@ SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi) packet.type = SR_DF_ANALOG; packet.payload = &analog; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); analog.num_samples = 1; analog.meaning->mqflags = 0; analog.data = &value; diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index f3d38f8c..5c9866e4 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -995,7 +995,8 @@ static int dlm_analog_samples_send(GArray *data, g_array_append_val(float_data, voltage); } - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); analog.meaning->channels = g_slist_append(NULL, ch); analog.num_samples = float_data->len; analog.data = (float*)float_data->data; diff --git a/src/input/wav.c b/src/input/wav.c index 18669304..4f5744a7 100644 --- a/src/input/wav.c +++ b/src/input/wav.c @@ -227,7 +227,8 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples) d += inc->unitsize; } - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); packet.type = SR_DF_ANALOG; packet.payload = &analog; analog.num_samples = num_samples; diff --git a/src/session_driver.c b/src/session_driver.c index 99d1c6cf..0fecd6b8 100644 --- a/src/session_driver.c +++ b/src/session_driver.c @@ -142,7 +142,8 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi) if (vdev->cur_analog_channel != 0) { packet.type = SR_DF_ANALOG; packet.payload = &analog; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); analog.meaning->channels = g_slist_prepend(NULL, g_array_index(vdev->analog_channels, struct sr_channel *, vdev->cur_analog_channel - 1));