From: Alexandru Gagniuc Date: Wed, 30 Mar 2016 02:21:55 +0000 (-0700) Subject: hp-3457a: Implement workaround for double-precision data X-Git-Tag: libsigrok-0.5.0~531 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=625430bf88ca7926ea386f6288f95f99290271ef;p=libsigrok.git hp-3457a: Implement workaround for double-precision data Certain output modules do not understand double-precision data. Although we need double precision to represent the full resolution of 7.5 digit readings, temporarily convert data to single precision so that the output modules understand it. While the reasing might be off by a few counts, we ensure the output modules do not display completely bogus data. For details, see bug #779. --- diff --git a/src/hardware/hp-3457a/protocol.c b/src/hardware/hp-3457a/protocol.c index 320d8d0a..618a99cd 100644 --- a/src/hardware/hp-3457a/protocol.c +++ b/src/hardware/hp-3457a/protocol.c @@ -216,9 +216,17 @@ static int calculate_num_zero_digits(double measurement, double range) return zero_digits; } +/* + * Until the output modules understand double precision data, we need to send + * the measurement as floats instead of doubles, hence, the dance with + * measurement_workaround double to float conversion. + * See bug #779 for details. + * The workaround should be removed once the output modules are fixed. + */ static void acq_send_measurement(struct sr_dev_inst *sdi) { double hires_measurement; + float measurement_workaround; int zero_digits, num_digits; struct sr_datafeed_packet packet; struct sr_datafeed_analog analog; @@ -241,12 +249,13 @@ static void acq_send_measurement(struct sr_dev_inst *sdi) packet.payload = &analog; sr_analog_init(&analog, &encoding, &meaning, &spec, num_digits); - encoding.unitsize = sizeof(double); + encoding.unitsize = sizeof(float); meaning.channels = sdi->channels; + measurement_workaround = hires_measurement; analog.num_samples = 1; - analog.data = &hires_measurement; + analog.data = &measurement_workaround; meaning.mq = devc->measurement_mq; meaning.unit = devc->measurement_unit;