uint8_t buf[3];
int ret;
+ (void)fd;
(void)revents;
sdi = cb_data;
buf[2] = 0x0d;
sr_spew("Sending init command: %02x %02x %02x.",
buf[0], buf[1], buf[2]);
- if ((ret = serial_write(fd, buf, 3)) < 0) {
+ if ((ret = serial_write(devc->serial, buf, 3)) < 0) {
sr_err("Error sending init command: %d.", ret);
return FALSE;
}
devc->state = GET_INIT_REPLY;
} else if (devc->state == GET_INIT_REPLY) {
/* If we just sent the "init" command, get its reply. */
- if ((ret = serial_read(fd, buf, 2)) < 0) {
+ if ((ret = serial_read(devc->serial, buf, 2)) < 0) {
sr_err("Error reading init reply: %d.", ret);
return FALSE;
}
buf[2] = 0x0d;
sr_spew("Sending data request command: %02x %02x %02x.",
buf[0], buf[1], buf[2]);
- if ((ret = serial_write(fd, buf, 3)) < 0) {
+ if ((ret = serial_write(devc->serial, buf, 3)) < 0) {
sr_err("Error sending request command: %d.", ret);
return FALSE;
}
devc->state = GET_PACKET;
} else if (devc->state == GET_PACKET) {
/* Read a packet from the device. */
- ret = serial_read(fd, devc->buf + devc->buflen,
+ ret = serial_read(devc->serial, devc->buf + devc->buflen,
4 - devc->buflen);
if (ret < 0) {
sr_err("Error reading packet: %d.", ret);
}
/* Stop acquisition if we acquired enough samples. */
- if (devc->limit_samples > 0) {
- if (devc->num_samples >= devc->limit_samples) {
- sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
- }
+ if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
+ sr_info("Requested number of samples reached.");
+ sdi->driver->dev_acquisition_stop(sdi, cb_data);
}
return TRUE;