X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Ftekpower-dmm%2Fprotocol.c;h=f1d01feeff42a7b425c5f9d988d0cee0c4e57c30;hb=39e5d79826cd2c1991007faf1a6cde05af995aa9;hp=87f83c15b5fb39606117c0010012d9320ad4272d;hpb=8c1adf3738b68912ab8cf4308341b82dbc83056a;p=libsigrok.git diff --git a/hardware/tekpower-dmm/protocol.c b/hardware/tekpower-dmm/protocol.c index 87f83c15..f1d01fee 100644 --- a/hardware/tekpower-dmm/protocol.c +++ b/hardware/tekpower-dmm/protocol.c @@ -29,6 +29,14 @@ /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature on this DMM. */ #define is_temperature info.is_c2c1_10 +static void log_dmm_packet(const uint8_t *buf) +{ + sr_dbg("DMM packet: %02x %02x %02x %02x %02x %02x %02x" + " %02x %02x %02x %02x %02x %02x %02x", + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], + buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]); +} + /* Now see what the value means, and pass that on. */ static void fs9721_serial_handle_packet(const uint8_t *buf, struct dev_context *devc) @@ -38,6 +46,8 @@ static void fs9721_serial_handle_packet(const uint8_t *buf, struct sr_datafeed_analog *analog; struct fs9721_info info; + log_dmm_packet(buf); + if (!(analog = g_try_malloc0(sizeof(struct sr_datafeed_analog)))) { sr_err("Analog packet malloc failed."); return; @@ -73,13 +83,13 @@ static void fs9721_serial_handle_packet(const uint8_t *buf, g_free(analog); } -static void handle_new_data(struct dev_context *devc, int fd) +static void handle_new_data(struct dev_context *devc) { int len, i, offset = 0; /* Try to get as much data as the buffer can hold. */ len = DMM_BUFSIZE - devc->buflen; - len = serial_read(fd, devc->buf + devc->buflen, len); + len = serial_read(devc->serial, devc->buf + devc->buflen, len); if (len < 1) { sr_err("Serial port read error: %d.", len); return; @@ -104,9 +114,11 @@ static void handle_new_data(struct dev_context *devc, int fd) SR_PRIV int tekpower_dmm_receive_data(int fd, int revents, void *cb_data) { - const struct sr_dev_inst *sdi; + struct sr_dev_inst *sdi; struct dev_context *devc; + (void)fd; + if (!(sdi = cb_data)) return TRUE; @@ -115,10 +127,11 @@ SR_PRIV int tekpower_dmm_receive_data(int fd, int revents, void *cb_data) if (revents == G_IO_IN) { /* Serial data arrived. */ - handle_new_data(devc, fd); + handle_new_data(devc); } if (devc->num_samples >= devc->limit_samples) { + sr_info("Requested number of samples reached, stopping."); sdi->driver->dev_acquisition_stop(sdi, cb_data); return TRUE; }