From: Uwe Hermann Date: Fri, 27 May 2016 15:33:46 +0000 (+0200) Subject: cem-dt-885x: Convert to SR_DF_ANALOG. X-Git-Tag: libsigrok-0.5.0~331 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7f9932e8db3192922674e441ef2978755fd98da7;p=libsigrok.git cem-dt-885x: Convert to SR_DF_ANALOG. --- diff --git a/src/hardware/cem-dt-885x/protocol.c b/src/hardware/cem-dt-885x/protocol.c index 25098185..65642775 100644 --- a/src/hardware/cem-dt-885x/protocol.c +++ b/src/hardware/cem-dt-885x/protocol.c @@ -66,7 +66,10 @@ static void process_mset(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_datafeed_packet packet; - struct sr_datafeed_analog_old analog; + struct sr_datafeed_analog analog; + struct sr_analog_encoding encoding; + struct sr_analog_meaning meaning; + struct sr_analog_spec spec; GString *dbg; float fvalue; int i; @@ -131,14 +134,14 @@ static void process_mset(const struct sr_dev_inst *sdi) break; } } - memset(&analog, 0, sizeof(struct sr_datafeed_analog_old)); - analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; - analog.mqflags = devc->cur_mqflags; - analog.unit = SR_UNIT_DECIBEL_SPL; - analog.channels = sdi->channels; + sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + analog.meaning->mq = SR_MQ_SOUND_PRESSURE_LEVEL; + analog.meaning->mqflags = devc->cur_mqflags; + analog.meaning->unit = SR_UNIT_DECIBEL_SPL; + analog.meaning->channels = sdi->channels; analog.num_samples = 1; analog.data = &devc->last_spl; - packet.type = SR_DF_ANALOG_OLD; + packet.type = SR_DF_ANALOG; packet.payload = &analog; sr_session_send(sdi, &packet); @@ -177,7 +180,10 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data, { struct dev_context *devc; struct sr_datafeed_packet packet; - struct sr_datafeed_analog_old analog; + struct sr_datafeed_analog analog; + struct sr_analog_encoding encoding; + struct sr_analog_meaning meaning; + struct sr_analog_spec spec; float fbuf[SAMPLES_PER_PACKET]; unsigned int i; @@ -189,14 +195,14 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data, fbuf[i] += ((data[i * 2 + 1] & 0xf0) >> 4); fbuf[i] += (data[i * 2 + 1] & 0x0f) / 10.0; } - memset(&analog, 0, sizeof(struct sr_datafeed_analog_old)); - analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; - analog.mqflags = devc->cur_mqflags; - analog.unit = SR_UNIT_DECIBEL_SPL; - analog.channels = sdi->channels; + sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + analog.meaning->mq = SR_MQ_SOUND_PRESSURE_LEVEL; + analog.meaning->mqflags = devc->cur_mqflags; + analog.meaning->unit = SR_UNIT_DECIBEL_SPL; + analog.meaning->channels = sdi->channels; analog.num_samples = num_samples; analog.data = fbuf; - packet.type = SR_DF_ANALOG_OLD; + packet.type = SR_DF_ANALOG; packet.payload = &analog; sr_session_send(sdi, &packet); diff --git a/src/hardware/cem-dt-885x/protocol.h b/src/hardware/cem-dt-885x/protocol.h index d6a94661..bb098422 100644 --- a/src/hardware/cem-dt-885x/protocol.h +++ b/src/hardware/cem-dt-885x/protocol.h @@ -90,7 +90,7 @@ enum { /** Private, per-device-instance driver context. */ struct dev_context { /* Device state */ - uint64_t cur_mqflags; + enum sr_mqflag cur_mqflags; int recording; int cur_meas_range; int cur_data_source;