Fix similar broken error handling on several serial calls.
This commit is contained in:
parent
7f22cd9554
commit
081c214eac
|
@ -116,9 +116,8 @@ static GSList *scan(GSList *options)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
serial_flush(serial);
|
serial_flush(serial);
|
||||||
if (serial_write_blocking(serial, "*IDN?\r\n", 7) == -1) {
|
if (serial_write_blocking(serial, "*IDN?\r\n", 7) < 7) {
|
||||||
sr_err("Unable to send identification string: %s.",
|
sr_err("Unable to send identification string.");
|
||||||
strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,8 @@ static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd)
|
||||||
strcat(buf, "\r\n");
|
strcat(buf, "\r\n");
|
||||||
else
|
else
|
||||||
strcat(buf, "\n\r\n");
|
strcat(buf, "\n\r\n");
|
||||||
if (serial_write_blocking(serial, buf, strlen(buf)) == -1) {
|
if (serial_write_blocking(serial, buf, strlen(buf)) < strlen(buf)) {
|
||||||
sr_err("Failed to send: %s.", strerror(errno));
|
sr_err("Failed to send.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,8 @@ static GSList *scan(GSList *options, int modelid)
|
||||||
memset(packet, 0, PACKET_SIZE);
|
memset(packet, 0, PACKET_SIZE);
|
||||||
packet[0] = 0xaa;
|
packet[0] = 0xaa;
|
||||||
packet[1] = 0xaa;
|
packet[1] = 0xaa;
|
||||||
if (serial_write_blocking(serial, packet, PACKET_SIZE) == -1) {
|
if (serial_write_blocking(serial, packet, PACKET_SIZE) < PACKET_SIZE) {
|
||||||
sr_err("Unable to write while probing for hardware: %s",
|
sr_err("Unable to write while probing for hardware.");
|
||||||
strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* The device responds with a 24-byte packet when it receives a packet.
|
/* The device responds with a 24-byte packet when it receives a packet.
|
||||||
|
|
|
@ -86,8 +86,8 @@ SR_PRIV void send_packet(const struct sr_dev_inst *sdi, uint8_t *packet)
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
if (serial_write_blocking(serial, packet, PACKET_SIZE) == -1)
|
if (serial_write_blocking(serial, packet, PACKET_SIZE) < PACKET_SIZE)
|
||||||
sr_dbg("Failed to send packet: %s", strerror(errno));
|
sr_dbg("Failed to send packet.");
|
||||||
dump_packet("sent", packet);
|
dump_packet("sent", packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,8 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
|
||||||
* we don't want it. */
|
* we don't want it. */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
/* Got 0x10, "measurement ready". */
|
/* Got 0x10, "measurement ready". */
|
||||||
if (serial_write_blocking(serial, "\x20", 1) == -1)
|
if (serial_write_blocking(serial, "\x20", 1) < 1)
|
||||||
sr_err("unable to send command: %s", strerror(errno));
|
sr_err("unable to send command");
|
||||||
else {
|
else {
|
||||||
devc->state = COMMAND_SENT;
|
devc->state = COMMAND_SENT;
|
||||||
devc->buflen = 0;
|
devc->buflen = 0;
|
||||||
|
|
|
@ -48,8 +48,8 @@ SR_PRIV int send_msg1(const struct sr_dev_inst *sdi, char cmd, int param)
|
||||||
|
|
||||||
sr_spew("send_msg1(): %c%c%c%c\\r", buf[0], buf[1], buf[2], buf[3]);
|
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) {
|
if (serial_write_blocking(serial, buf, sizeof(buf)) < sizeof(buf)) {
|
||||||
sr_err("Write error for cmd=%c: %d %s", cmd, errno, strerror(errno));
|
sr_err("Write error for cmd=%c", cmd);
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1307,7 +1307,7 @@ int req_meas14(const struct sr_dev_inst *sdi)
|
||||||
devc->cmd_idx = 0;
|
devc->cmd_idx = 0;
|
||||||
create_cmd_14(devc->addr, 8, params, msg);
|
create_cmd_14(devc->addr, 8, params, msg);
|
||||||
devc->req_sent_at = g_get_monotonic_time();
|
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;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,7 +1350,7 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
|
||||||
|
|
||||||
/* Write message and wait for reply */
|
/* Write message and wait for reply */
|
||||||
devc->req_sent_at = g_get_monotonic_time();
|
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;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue