]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/motech-lps-30x/protocol.c
scpi-pps: Add a missing "break" in config_get().
[libsigrok.git] / src / hardware / motech-lps-30x / protocol.c
index 80b799d9e9dd1c08cf0590fa055af97729b957b6..b31f2ee1d33ad83bcf48f33e8881a32f55290f4b 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** @file
- *  <em>Motech LPS-30x series</em> power supply driver
- *  @internal
- */
-
 #include <config.h>
 #include <errno.h>
 #include <string.h>
@@ -44,6 +39,7 @@ static void send_data(struct sr_dev_inst *sdi)
        packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
 
+       /* Note: digits/spec_digits will be overridden later. */
        sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
 
        analog.meaning->channels = sdi->channels;
@@ -51,6 +47,8 @@ static void send_data(struct sr_dev_inst *sdi)
        analog.meaning->mq = SR_MQ_VOLTAGE;
        analog.meaning->unit = SR_UNIT_VOLT;
        analog.meaning->mqflags = SR_MQFLAG_DC;
+       analog.encoding->digits = 3;
+       analog.spec->spec_digits = 2;
        analog.data = data;
 
        for (i = 0; i < devc->model->num_channels; i++)
@@ -60,6 +58,8 @@ static void send_data(struct sr_dev_inst *sdi)
        analog.meaning->mq = SR_MQ_CURRENT;
        analog.meaning->unit = SR_UNIT_AMPERE;
        analog.meaning->mqflags = 0;
+       analog.encoding->digits = 4;
+       analog.spec->spec_digits = 3;
        analog.data = data;
        for (i = 0; i < devc->model->num_channels; i++)
                ((float *)analog.data)[i] = devc->channel_status[i].output_current_last; /* Value always 0 for channel 3, if present! */
@@ -76,6 +76,8 @@ static void process_line(struct sr_dev_inst *sdi)
        int auxint;
 
        devc = sdi->priv;
+       if (!devc)
+               return;
 
        switch (devc->acq_req_pending) {
        case 0: /* Should not happen... */
@@ -87,13 +89,15 @@ static void process_line(struct sr_dev_inst *sdi)
                case AQ_U2:
                case AQ_I1:
                case AQ_I2:
-                       if (sr_atod(devc->buf, &dbl) != SR_OK) {
+                       dbl = 0.0;
+                       if (sr_atod_ascii(devc->buf, &dbl) != SR_OK) {
                                sr_err("Failed to convert '%s' to double, errno=%d %s",
                                        devc->buf, errno, g_strerror(errno));
                                dbl = 0.0;
                        }
                        break;
                case AQ_STATUS:
+                       auxint = 0;
                        if (sr_atoi(devc->buf, &auxint) != SR_OK) {
                                sr_err("Failed to convert '%s' to int, errno=%d %s",
                                        devc->buf, errno, g_strerror(errno));
@@ -185,7 +189,7 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        /* Only request the next packet if required. */
        if (!((sdi->status == SR_ST_ACTIVE) && (devc->acq_running)))