Return SR_OK in case of successful transmission of a packet request. The
previous implementation passed the serial layer's verbatim return value,
which was non-negative non-null (read: above zero) in case of success,
which is none of the expected return codes of a packet request routine.
This amends commit
379e95c587e1d and completes the adjustment which was
started in commit
a4be2b327be8. The issue has gone unnoticed in the past
since it took not effect. The serial-dmm caller only tested for negative
return values.
SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
{
const uint8_t wbuf = 'D';
+ size_t wrlen;
+ int ret;
sr_spew("Requesting DMM packet.");
- return serial_write_blocking(serial, &wbuf, 1, 0);
+ wrlen = sizeof(wbuf);
+ ret = serial_write_blocking(serial, &wbuf, wrlen, 0);
+ if (ret < 0)
+ return ret;
+ if ((size_t)ret != wrlen)
+ return SR_ERR_IO;
+
+ return SR_OK;
}
#endif