Hello!

I recently started tinkering with sigrok and noticed that using my Bus Pirate 
in OLS mode was very unreliable (succeeding maybe 10% of the time). It looked 
like this was due to a number of different factors:

• Buspirate sometimes (always?) sends a response to being reset, which 
potentially could be mistaken for an invalid ID response. I added code to flush 
the input after sending the resets.
• It appeared that both the ID and the metadata sometimes arrived late. 
Increasing the timeouts fixed this so connections now work 100% of the time. 
However, I did not systematically check whether tighter timeouts would still 
work; maybe 50ms is too conservative.

Regards
Matthias Neeracher

---
 hardware/openbench-logic-sniffer/api.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hardware/openbench-logic-sniffer/api.c 
b/hardware/openbench-logic-sniffer/api.c
index 3853299..acf5e5c 100644
--- a/hardware/openbench-logic-sniffer/api.c
+++ b/hardware/openbench-logic-sniffer/api.c
@@ -150,10 +150,13 @@ static GSList *scan(GSList *options)
                sr_err("Could not use port %s. Quitting.", conn);
                return NULL;
        }
+       sp_drain(serial);
+       g_usleep(10000);
+       serial_flush(serial);
        send_shortcommand(serial, CMD_ID);
 
-       /* Wait 10ms for a response. */
-       g_usleep(10000);
+       /* Wait 50ms for a response. */
+       g_usleep(50000);
 
        sp_get_port_handle(serial->data, &probefd.fd);
        probefd.events = G_IO_IN;
@@ -170,7 +173,7 @@ static GSList *scan(GSList *options)
         * the metadata command.
         */
        send_shortcommand(serial, CMD_METADATA);
-       if (g_poll(&probefd, 1, 10) > 0) {
+       if (g_poll(&probefd, 1, 50) > 0) {
                /* Got metadata. */
                sdi = get_metadata(serial);
                sdi->index = 0;
-- 
1.7.12.4 (Apple Git-37)


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to