X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fopenbench-logic-sniffer%2Fprotocol.c;h=584164e7ba412e02382b257ebc73a0339f4cebed;hb=f57d8ffe66612a1fdc20ed09c222f8ea59bd84d4;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..584164e7 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;