X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbrymen-dmm%2Fprotocol.c;h=5a7f2252a7e701639278207d2ad880de30942a49;hb=89a3d8af3a5f3a1d265ec396fdb3d4c9d69ee7c3;hp=1667bef688cbbe9fc6c6d0a5a6188a53b5d7d7cf;hpb=695dc859c15ba4190f5c1aa2e1a6e2dc6a6e5845;p=libsigrok.git diff --git a/src/hardware/brymen-dmm/protocol.c b/src/hardware/brymen-dmm/protocol.c index 1667bef6..5a7f2252 100644 --- a/src/hardware/brymen-dmm/protocol.c +++ b/src/hardware/brymen-dmm/protocol.c @@ -25,25 +25,31 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi) float floatval; 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; devc = sdi->priv; + /* TODO: Use proper 'digits' value for this device (and its modes). */ + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); + analog.num_samples = 1; - analog.mq = -1; + analog.meaning->mq = 0; if (brymen_parse(buf, &floatval, &analog, NULL) != SR_OK) return; analog.data = &floatval; - analog.channels = sdi->channels; + analog.meaning->channels = sdi->channels; - if (analog.mq != -1) { + if (analog.meaning->mq != 0) { /* Got a measurement. */ - packet.type = SR_DF_ANALOG_OLD; + packet.type = SR_DF_ANALOG; packet.payload = &analog; sr_session_send(sdi, &packet); - devc->num_samples++; + sr_sw_limits_update_samples_read(&devc->sw_limits, 1); } } @@ -114,7 +120,6 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data) struct dev_context *devc; struct sr_serial_dev_inst *serial; int ret; - int64_t time; (void)fd; @@ -137,20 +142,8 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data) } } - if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { - sr_info("Requested number of samples reached, stopping."); + if (sr_sw_limits_check(&devc->sw_limits)) sdi->driver->dev_acquisition_stop(sdi); - return TRUE; - } - - if (devc->limit_msec) { - time = (g_get_monotonic_time() - devc->starttime) / 1000; - if (time > (int64_t)devc->limit_msec) { - sr_info("Requested time limit reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi); - return TRUE; - } - } return TRUE; }