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.
This commit is contained in:
parent
869c837511
commit
7dcaddd3f0
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue