X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fopenbench-logic-sniffer%2Fprotocol.c;h=b732da59c19e5a271b553a9be7288186e6cb6530;hb=5e1b68c6e7567e0dcf7aff1307c3ffd4852cc15a;hp=00068ebdcb4e37145ce7f9363c6cf446b3c826c0;hpb=f4d3a4fb9ae62b4764cbb8181ab9bef95e7b6348;p=libsigrok.git diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 00068ebd..b732da59 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -33,6 +33,9 @@ SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial, if (serial_write_blocking(serial, buf, 1, serial_timeout(serial, 1)) != 1) return SR_ERR; + if (serial_drain(serial) != 0) + return SR_ERR; + return SR_OK; } @@ -51,6 +54,9 @@ SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial, if (serial_write_blocking(serial, buf, 5, serial_timeout(serial, 1)) != 5) return SR_ERR; + if (serial_drain(serial) != 0) + return SR_ERR; + return SR_OK; } @@ -118,10 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void) { struct dev_context *devc; - if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { - sr_err("Device context malloc failed."); - return NULL; - } + devc = g_malloc0(sizeof(struct dev_context)); /* Device-specific settings */ devc->max_samples = devc->max_samplerate = devc->protocol_version = 0; @@ -146,7 +149,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) GString *tmp_str, *devname, *version; guchar tmp_c; - sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL); + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; sdi->driver = di; devc = ols_dev_new(); sdi->priv = devc; @@ -212,9 +216,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) case 0x00: /* Number of usable channels */ for (ui = 0; ui < tmp_int; ui++) { - if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, - ols_channel_names[ui]))) - return 0; + ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, + ols_channel_names[ui]); sdi->channels = g_slist_append(sdi->channels, ch); } break; @@ -251,9 +254,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) case 0x00: /* Number of usable channels */ for (ui = 0; ui < tmp_c; ui++) { - if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, - ols_channel_names[ui]))) - return 0; + ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, + ols_channel_names[ui]); sdi->channels = g_slist_append(sdi->channels, ch); } break;