gmc-mh-1x-2x: Make serial write calls block.

These calls are executed from an event handler and were previously nonblocking,
but have no partial write handling. They send short packets so should be OK to
block, most likely the output buffer will be empty anyway.

Fix error handling for some: serial_write can return any negative error code.
This commit is contained in:
Martin Ling 2014-09-21 18:44:20 +01:00 committed by Uwe Hermann
parent e1960467ce
commit 612db3c44b
1 changed files with 5 additions and 5 deletions

View 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(serial, msg, sizeof(msg)) == -1) {
if (serial_write_blocking(serial, msg, sizeof(msg)) < 0) {
return SR_ERR;
}
@ -1336,13 +1336,13 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
if (power_on) {
sr_info("Write some data and wait 3s to turn on powered off device...");
if (serial_write(serial, msg, sizeof(msg)) < 0)
if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
if (serial_write(serial, msg, sizeof(msg)) < 0)
if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
if (serial_write(serial, msg, sizeof(msg)) < 0)
if (serial_write_blocking(serial, msg, sizeof(msg)) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
serial_flush(serial);
@ -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(serial, msg, sizeof(msg)) == -1) {
if (serial_write_blocking(serial, msg, sizeof(msg)) < 0) {
return SR_ERR;
}