X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbrymen-dmm%2Fprotocol.c;h=5a7f2252a7e701639278207d2ad880de30942a49;hb=caeb8d7a9d2d5a2497692a23caf066f33f7a34c3;hp=02e14d3198fd6e0a75bd6eba45160e8da8b102ab;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git
diff --git a/src/hardware/brymen-dmm/protocol.c b/src/hardware/brymen-dmm/protocol.c
index 02e14d31..5a7f2252 100644
--- a/src/hardware/brymen-dmm/protocol.c
+++ b/src/hardware/brymen-dmm/protocol.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include "protocol.h"
static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
@@ -25,24 +26,30 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
struct dev_context *devc;
struct sr_datafeed_packet packet;
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;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
- devc->num_samples++;
+ sr_session_send(sdi, &packet);
+ sr_sw_limits_update_samples_read(&devc->sw_limits, 1);
}
}
@@ -113,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;
@@ -136,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.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
- 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, cb_data);
- return TRUE;
- }
- }
+ if (sr_sw_limits_check(&devc->sw_limits))
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}