]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/lascar-el-usb/protocol.c
sr_dev_close(): Set status to SR_ST_INACTIVE.
[libsigrok.git] / src / hardware / lascar-el-usb / protocol.c
index 901b2525cb609420b67b927d9047c136bd97b582..03fbf25210f5d91da339f52e2af054875a6229e0 100644 (file)
@@ -398,6 +398,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
 
        devc = sdi->priv;
 
+       /* Note: digits/spec_digits will be overridden later. */
        sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
 
        samples = buflen / devc->sample_size;
@@ -434,10 +435,15 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
                if (ch->enabled) {
                        analog.meaning->channels = g_slist_append(NULL, ch);
                        analog.meaning->mq = SR_MQ_TEMPERATURE;
-                       if (devc->temp_unit == 1)
+                       if (devc->temp_unit == 1) {
                                analog.meaning->unit = SR_UNIT_FAHRENHEIT;
-                       else
+                               analog.encoding->digits = 0;
+                               analog.spec->spec_digits = 0;
+                       } else {
                                analog.meaning->unit = SR_UNIT_CELSIUS;
+                               analog.encoding->digits = 1;
+                               analog.spec->spec_digits = 1;
+                       }
                        analog.data = (void *)temp;
                        sr_session_send(sdi, &packet);
                        g_slist_free(analog.meaning->channels);
@@ -448,6 +454,8 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
                        analog.meaning->channels = g_slist_append(NULL, ch);
                        analog.meaning->mq = SR_MQ_RELATIVE_HUMIDITY;
                        analog.meaning->unit = SR_UNIT_PERCENTAGE;
+                       analog.encoding->digits = 1;
+                       analog.spec->spec_digits = 1;
                        analog.data = (void *)rh;
                        sr_session_send(sdi, &packet);
                        g_slist_free(analog.meaning->channels);
@@ -520,7 +528,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
        switch (transfer->status) {
        case LIBUSB_TRANSFER_NO_DEVICE:
                /* USB device was unplugged. */
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return;
        case LIBUSB_TRANSFER_COMPLETED:
        case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
@@ -539,7 +547,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
                                devc->rcvd_bytes, devc->log_size,
                                devc->rcvd_samples, devc->logged_samples);
                if (devc->rcvd_bytes >= devc->log_size)
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
        }
 
        if (sdi->status == SR_ST_ACTIVE) {
@@ -549,7 +557,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
                               libusb_error_name(ret));
                        g_free(transfer->buffer);
                        libusb_free_transfer(transfer);
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
        } else {
                /* This was the last transfer we're going to receive, so