]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/brymen-dmm/protocol.c
Have remaining drivers default to digits=2 for analog values.
[libsigrok.git] / src / hardware / brymen-dmm / protocol.c
index 1667bef688cbbe9fc6c6d0a5a6188a53b5d7d7cf..5a7f2252a7e701639278207d2ad880de30942a49 100644 (file)
@@ -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;
 }