]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/cem-dt-885x/protocol.c
drivers: Use serial_write_blocking() everywhere.
[libsigrok.git] / src / hardware / cem-dt-885x / protocol.c
index 65642775558c8c27a5fa69ba44e78e61ac5d559a..f6e05de9693845aee20dfb30e3508fd3f474b254 100644 (file)
@@ -134,7 +134,7 @@ static void process_mset(const struct sr_dev_inst *sdi)
                                break;
                        }
                }
-               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+               sr_analog_init(&analog, &encoding, &meaning, &spec, 1);
                analog.meaning->mq = SR_MQ_SOUND_PRESSURE_LEVEL;
                analog.meaning->mqflags = devc->cur_mqflags;
                analog.meaning->unit = SR_UNIT_DECIBEL_SPL;
@@ -147,7 +147,7 @@ static void process_mset(const struct sr_dev_inst *sdi)
 
                devc->num_samples++;
                if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
-                       sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+                       sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
                break;
        case TOKEN_RECORDING_ON:
                devc->recording = TRUE;
@@ -195,7 +195,7 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
                fbuf[i] += ((data[i * 2 + 1] & 0xf0) >> 4);
                fbuf[i] += (data[i * 2 + 1] & 0x0f) / 10.0;
        }
-       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 1);
        analog.meaning->mq = SR_MQ_SOUND_PRESSURE_LEVEL;
        analog.meaning->mqflags = devc->cur_mqflags;
        analog.meaning->unit = SR_UNIT_DECIBEL_SPL;
@@ -208,7 +208,7 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
 
        devc->num_samples += analog.num_samples;
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
-               sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+               sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
 
        return;
 }
@@ -321,7 +321,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
                         * records. Otherwise the frontend would have no
                         * way to tell where stored data ends and live
                         * measurements begin. */
-                       sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+                       sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
                } else if (c == RECORD_DATA) {
                        devc->buf_len = 0;
                        devc->state = ST_GET_LOG_RECORD_DATA;
@@ -400,7 +400,7 @@ SR_PRIV int cem_dt_885x_receive_data(int fd, int revents, void *cb_data)
                        } else {
                                /* Tell device to start transferring from memory. */
                                cmd = CMD_TRANSFER_MEMORY;
-                               serial_write_nonblocking(serial, &cmd, 1);
+                               serial_write_blocking(serial, &cmd, 1, 0);
                        }
                }
        }
@@ -456,7 +456,7 @@ static int cem_dt_885x_toggle(const struct sr_dev_inst *sdi, uint8_t cmd,
         * only thing to do is wait for the token that will confirm
         * whether the command worked or not, and resend if needed. */
        while (TRUE) {
-               if (serial_write_nonblocking(serial, (const void *)&cmd, 1) != 1)
+               if (serial_write_blocking(serial, (const void *)&cmd, 1, 0) < 0)
                        return SR_ERR;
                if (wait_for_token(sdi, tokens, timeout) == SR_ERR)
                        return SR_ERR;
@@ -770,11 +770,11 @@ SR_PRIV int cem_dt_885x_meas_range_set(const struct sr_dev_inst *sdi,
        devc = sdi->priv;
        if (low == 30 && high == 130)
                token = TOKEN_MEAS_RANGE_30_130;
-       else if (low == 30 &&  high == 80)
+       else if (low == 30 && high == 80)
                token = TOKEN_MEAS_RANGE_30_80;
-       else if (low == 50 &&  high == 100)
+       else if (low == 50 && high == 100)
                token = TOKEN_MEAS_RANGE_50_100;
-       else if (low == 80 &&  high == 130)
+       else if (low == 80 && high == 130)
                token = TOKEN_MEAS_RANGE_80_130;
        else
                return SR_ERR;
@@ -817,7 +817,7 @@ SR_PRIV int cem_dt_885x_power_off(const struct sr_dev_inst *sdi)
        cmd = CMD_TOGGLE_POWER_OFF;
        while (TRUE) {
                serial_flush(serial);
-               if (serial_write_nonblocking(serial, (const void *)&cmd, 1) != 1)
+               if (serial_write_blocking(serial, (const void *)&cmd, 1, 0) < 0)
                        return SR_ERR;
                /* It never takes more than 23ms for the next token to arrive. */
                g_usleep(25 * 1000);