return NULL;
serial_flush(serial);
- if (serial_write_blocking(serial, "*IDN?\r\n", 7) == -1) {
- sr_err("Unable to send identification string: %s.",
- strerror(errno));
+ if (serial_write_blocking(serial, "*IDN?\r\n", 7) < 7) {
+ sr_err("Unable to send identification string.");
return NULL;
}
strcat(buf, "\r\n");
else
strcat(buf, "\n\r\n");
- if (serial_write_blocking(serial, buf, strlen(buf)) == -1) {
- sr_err("Failed to send: %s.", strerror(errno));
+ if (serial_write_blocking(serial, buf, strlen(buf)) < strlen(buf)) {
+ sr_err("Failed to send.");
return SR_ERR;
}
memset(packet, 0, PACKET_SIZE);
packet[0] = 0xaa;
packet[1] = 0xaa;
- if (serial_write_blocking(serial, packet, PACKET_SIZE) == -1) {
- sr_err("Unable to write while probing for hardware: %s",
- strerror(errno));
+ if (serial_write_blocking(serial, packet, PACKET_SIZE) < PACKET_SIZE) {
+ sr_err("Unable to write while probing for hardware.");
return NULL;
}
/* The device responds with a 24-byte packet when it receives a packet.
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
- if (serial_write_blocking(serial, packet, PACKET_SIZE) == -1)
- sr_dbg("Failed to send packet: %s", strerror(errno));
+ if (serial_write_blocking(serial, packet, PACKET_SIZE) < PACKET_SIZE)
+ sr_dbg("Failed to send packet.");
dump_packet("sent", packet);
}
* we don't want it. */
return TRUE;
/* Got 0x10, "measurement ready". */
- if (serial_write_blocking(serial, "\x20", 1) == -1)
- sr_err("unable to send command: %s", strerror(errno));
+ if (serial_write_blocking(serial, "\x20", 1) < 1)
+ sr_err("unable to send command");
else {
devc->state = COMMAND_SENT;
devc->buflen = 0;
sr_spew("send_msg1(): %c%c%c%c\\r", buf[0], buf[1], buf[2], buf[3]);
- if (serial_write_blocking(serial, buf, sizeof(buf)) == -1) {
- sr_err("Write error for cmd=%c: %d %s", cmd, errno, strerror(errno));
+ if (serial_write_blocking(serial, buf, sizeof(buf)) < sizeof(buf)) {
+ sr_err("Write error for cmd=%c", cmd);
return SR_ERR;
}
devc->cmd_idx = 0;
create_cmd_14(devc->addr, 8, params, msg);
devc->req_sent_at = g_get_monotonic_time();
- if (serial_write_blocking(serial, msg, sizeof(msg)) == -1) {
+ if (serial_write_blocking(serial, msg, sizeof(msg)) < sizeof(msg)) {
return SR_ERR;
}
/* Write message and wait for reply */
devc->req_sent_at = g_get_monotonic_time();
- if (serial_write_blocking(serial, msg, sizeof(msg)) == -1) {
+ if (serial_write_blocking(serial, msg, sizeof(msg)) < sizeof(msg)) {
return SR_ERR;
}