Hi, * PROBLEM: open logic sniffer (ols) driver does not work on FreeBSD (10.0)
sigrok-cli is unable to detect the ols device. Example: the following command does not work (on FreeBSD): # sigrok-cli -d ols:conn=/dev/ttyU0 --scan * FIX:send_shortcommand() and send_longcommand() did not ensure that the commands were actually sent. Hence the initial 5 times reset followed by identify never left the buffer.
The attached patch (against HEAD) fixes above described problem on FreeBSD (10.0)
/Uffe
diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 1c94b7f..ebdcb4a 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -2,6 +2,7 @@ * This file is part of the libsigrok project. * * Copyright (C) 2013 Bert Vermeulen <[email protected]> + * Copyright (C) 2014 Uffe Jakobsen <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +34,9 @@ SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial, if (serial_write_blocking(serial, buf, 1) != 1) return SR_ERR; + if (serial_drain(serial) != 0) + return SR_ERR; + return SR_OK; } @@ -51,6 +55,9 @@ SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial, if (serial_write_blocking(serial, buf, 5) != 5) return SR_ERR; + if (serial_drain(serial) != 0) + return SR_ERR; + return SR_OK; } diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 2ab6347..c8c970d 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -2,6 +2,7 @@ * This file is part of the libsigrok project. * * Copyright (C) 2013 Bert Vermeulen <[email protected]> + * Copyright (C) 2014 Uffe Jakobsen <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -626,6 +627,7 @@ typedef gboolean (*packet_valid_callback)(const uint8_t *buf); SR_PRIV int serial_open(struct sr_serial_dev_inst *serial, int flags); SR_PRIV int serial_close(struct sr_serial_dev_inst *serial); SR_PRIV int serial_flush(struct sr_serial_dev_inst *serial); +SR_PRIV int serial_drain(struct sr_serial_dev_inst *serial); SR_PRIV int serial_write(struct sr_serial_dev_inst *serial, const void *buf, size_t count); SR_PRIV int serial_write_blocking(struct sr_serial_dev_inst *serial, diff --git a/src/serial.c b/src/serial.c index 705c52d..fd36950 100644 --- a/src/serial.c +++ b/src/serial.c @@ -4,6 +4,7 @@ * Copyright (C) 2010-2012 Bert Vermeulen <[email protected]> * Copyright (C) 2010-2012 Uwe Hermann <[email protected]> * Copyright (C) 2012 Alexandru Gagniuc <[email protected]> + * Copyright (C) 2014 Uffe Jakobsen <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -171,6 +172,44 @@ SR_PRIV int serial_flush(struct sr_serial_dev_inst *serial) return SR_OK; } +/** + * Drain serial port buffers. + * + * @param serial Previously initialized serial port structure. + * + * @retval SR_OK Success. + * @retval SR_ERR Failure. + */ +SR_PRIV int serial_drain(struct sr_serial_dev_inst *serial) +{ + int ret; + char *error; + + if (!serial) { + sr_dbg("Invalid serial port."); + return SR_ERR; + } + + if (!serial->data) { + sr_dbg("Cannot drain unopened serial port %s.", serial->port); + return SR_ERR; + } + + sr_spew("Draining serial port %s.", serial->port); + + ret = sp_drain(serial->data); + + if (ret == SP_ERR_FAIL) { + error = sp_last_error_message(); + sr_err("Error draining port (%d): %s.", + sp_last_error_code(), error); + sp_free_error_message(error); + return SR_ERR; + } + + return SR_OK; +} + static int _serial_write(struct sr_serial_dev_inst *serial, const void *buf, size_t count, int nonblocking) {
------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________ sigrok-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sigrok-devel

