]> sigrok.org Git - libsigrok.git/commitdiff
Fix similar broken error handling on several serial calls.
authorMartin Ling <redacted>
Sun, 28 Sep 2014 11:54:56 +0000 (12:54 +0100)
committerBert Vermeulen <redacted>
Thu, 2 Oct 2014 13:57:02 +0000 (15:57 +0200)
src/hardware/agilent-dmm/api.c
src/hardware/agilent-dmm/sched.c
src/hardware/atten-pps3xxx/api.c
src/hardware/atten-pps3xxx/protocol.c
src/hardware/colead-slm/protocol.c
src/hardware/conrad-digi-35-cpu/protocol.c
src/hardware/gmc-mh-1x-2x/protocol.c

index e4240e623cdacbb0d76069e531a7bffd30963e66..b7ae7fb280d95ebace2ca9643d34b88107555dbc 100644 (file)
@@ -116,9 +116,8 @@ static GSList *scan(GSList *options)
                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;
        }
 
index df65113407b2713a650e3fc57e8696b71a2169ba..b555cd8b93b4c5a1761f96d518fdf9b8a2454f3a 100644 (file)
@@ -140,8 +140,8 @@ static int agdmm_send(const struct sr_dev_inst *sdi, const char *cmd)
                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;
        }
 
index 75a1fbbd3e3355ce75096fed5b93fc303995c934..a0f84152405f6725c2af1dc2a7ed48fc818c9e61 100644 (file)
@@ -130,9 +130,8 @@ static GSList *scan(GSList *options, int modelid)
        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.
index 66ecb7a28ff2cde835de7db59c122e3685283963..95137d2e9a8164e86041d5184129ab749173c75f 100644 (file)
@@ -86,8 +86,8 @@ SR_PRIV void send_packet(const struct sr_dev_inst *sdi, uint8_t *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);
 }
 
index 6b89ea14f512aeb9202e74f8f5e5a424801c0c7b..6864cb68ee8615f369f478051ff2807e03ace329 100644 (file)
@@ -207,8 +207,8 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
                         * 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;
index cfabdc7b778a72c38397618e295cdec11587e633..6b1d0d56af1c8923a5680452625f4983ad5b4640 100644 (file)
@@ -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]);
 
-       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;
        }
 
index cfcbc4dc6b4aee1b01a1ee338a0cb045b0a09af9..3ba4f4ffab27565ce72456a8eac4268aacf130c3 100644 (file)
@@ -1307,7 +1307,7 @@ int req_meas14(const struct sr_dev_inst *sdi)
        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;
        }
 
@@ -1350,7 +1350,7 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
 
        /* 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;
        }