X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Fmic-985xx%2Fprotocol.c;h=ce5f0209649e3afc00a4f4f5c6b3accf508ff7a5;hp=5f2825e65b740103d56e101f052cb4fa85497704;hb=ba7dd8bbb8168cba432a844259a3e239aa5f36d7;hpb=ff17e6ba5094d590926a2aa8130220a341fc2c04 diff --git a/hardware/mic-985xx/protocol.c b/hardware/mic-985xx/protocol.c index 5f2825e6..ce5f0209 100644 --- a/hardware/mic-985xx/protocol.c +++ b/hardware/mic-985xx/protocol.c @@ -111,15 +111,15 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) /* Clear 'analog', otherwise it'll contain random garbage. */ memset(&analog, 0, sizeof(struct sr_datafeed_analog)); - /* Common values for both probes. */ + /* Common values for both channels. */ packet.type = SR_DF_ANALOG; packet.payload = &analog; analog.num_samples = 1; /* Temperature. */ - l = g_slist_copy(sdi->probes); + l = g_slist_copy(sdi->channels); l = g_slist_remove_link(l, g_slist_nth(l, 1)); - analog.probes = l; + analog.channels = l; analog.mq = SR_MQ_TEMPERATURE; analog.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */ analog.data = &temperature; @@ -128,9 +128,9 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) /* Humidity. */ if (mic_devs[idx].has_humidity) { - l = g_slist_copy(sdi->probes); + l = g_slist_copy(sdi->channels); l = g_slist_remove_link(l, g_slist_nth(l, 0)); - analog.probes = l; + analog.channels = l; analog.mq = SR_MQ_RELATIVE_HUMIDITY; analog.unit = SR_UNIT_PERCENTAGE; analog.data = &humidity; @@ -146,13 +146,15 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) static void handle_new_data(struct sr_dev_inst *sdi, int idx) { struct dev_context *devc; + struct sr_serial_dev_inst *serial; int len, i, offset = 0; devc = sdi->priv; + serial = sdi->conn; /* Try to get as much data as the buffer can hold. */ len = SERIAL_BUFSIZE - devc->buflen; - len = serial_read(devc->serial, devc->buf + devc->buflen, len); + len = serial_read(serial, devc->buf + devc->buflen, len); if (len < 1) { sr_err("Serial port read error: %d.", len); return; @@ -182,6 +184,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) struct dev_context *devc; int64_t t; static gboolean first_time = TRUE; + struct sr_serial_dev_inst *serial; (void)fd; @@ -191,13 +194,15 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) if (!(devc = sdi->priv)) return TRUE; + serial = sdi->conn; + if (revents == G_IO_IN) { /* New data arrived. */ handle_new_data(sdi, idx); } else { /* Timeout. */ if (first_time) { - mic_cmd_set_realtime_mode(devc->serial); + mic_cmd_set_realtime_mode(serial); first_time = FALSE; } }