This fixes bug #962.
sr_spew("Requesting DMM packet.");
- return (serial_write_nonblocking(serial, &wbuf, 1) == 1) ? SR_OK : SR_ERR;
+ return serial_write_blocking(serial, &wbuf, 1, 0);
}
#endif
} 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);
}
}
}
* 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;
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);
serial_flush(serial);
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
- if (serial_write_nonblocking(serial, "O1\r\n", 4) != 4)
+ if (serial_write_blocking(serial, "O1\r\n", 4, 0) < 0)
goto scan_cleanup;
/* Device replies with "A00\r\n" (OK) or "E01\r\n" (Error). Ignore. */
serial = sdi->conn;
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
- if (serial_write_nonblocking(serial, "O1\r\n", 4) != 4)
+ if (serial_write_blocking(serial, "O1\r\n", 4, 0) < 0)
return SR_ERR;
/* Device replies with "A00\r\n" (OK) or "E01\r\n" (Error). Ignore. */
if (!(serial = sdi->conn))
return SR_ERR;
- if (serial_write_nonblocking(serial, (const void *)buffer, 2) != 2)
- return SR_ERR;
-
- return SR_OK;
+ return serial_write_blocking(serial, (const void *)buffer, 2, 0);
}
static int send_long_command(const struct sr_dev_inst *sdi, uint32_t command)
if (!(serial = sdi->conn))
return SR_ERR;
- if (serial_write_nonblocking(serial, (const void *)buffer, 4) != 4)
- return SR_ERR;
-
- return SR_OK;
+ return serial_write_blocking(serial, (const void *)buffer, 4, 0);
}
static void send_data(const struct sr_dev_inst *sdi, float sample)
uint8_t slave_addr = modbus->slave_addr;
uint16_t crc;
- result = serial_write_nonblocking(serial, &slave_addr, sizeof(slave_addr));
+ result = serial_write_blocking(serial, &slave_addr, sizeof(slave_addr), 0);
if (result < 0)
return result;
- result = serial_write_nonblocking(serial, buffer, buffer_size);
+ result = serial_write_blocking(serial, buffer, buffer_size, 0);
if (result < 0)
return result;
crc = modbus_serial_rtu_crc(0xFFFF, &slave_addr, sizeof(slave_addr));
crc = modbus_serial_rtu_crc(crc, buffer, buffer_size);
- result = serial_write_nonblocking(serial, &crc, sizeof(crc));
+ result = serial_write_blocking(serial, &crc, sizeof(crc), 0);
if (result < 0)
return result;
static int scpi_serial_send(void *priv, const char *command)
{
- int len, result, written;
+ int result;
struct scpi_serial *sscpi = priv;
struct sr_serial_dev_inst *serial = sscpi->serial;
- len = strlen(command);
- written = 0;
- while (written < len) {
- result = serial_write_nonblocking(serial,
- command + written, len - written);
- if (result < 0) {
- sr_err("Error while sending SCPI command: '%s'.", command);
- return SR_ERR;
- }
- written += result;
+ result = serial_write_blocking(serial, command, strlen(command), 0);
+ if (result < 0) {
+ sr_err("Error while sending SCPI command: '%s'.", command);
+ return SR_ERR;
}
sr_spew("Successfully sent SCPI command: '%s'.", command);