Applies to both branches
--
Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 9a2ed1c1854f3c2443e167f035aa3f6751da0b4a Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Jan 2011 16:21:42 +0100
Subject: Safer initialasation of ftdi_readstream:
- switch to reset mode first
- purge all buffers
---
src/ftdi_stream.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c
index 6c40327..6b5b61c 100644
--- a/src/ftdi_stream.c
+++ b/src/ftdi_stream.c
@@ -153,6 +153,20 @@ ftdi_readstream(struct ftdi_context *ftdi,
int xferIndex;
int err = 0;
+ /* We don't know in what state we are, switch to reset*/
+ if (ftdi_set_bitmode(ftdi, 0xff, BITMODE_RESET) < 0)
+ {
+ fprintf(stderr,"Can't reset mode\n");
+ return 1;
+ }
+
+ /* Purge anything remaining in the buffers*/
+ if (ftdi_usb_purge_buffers(ftdi) < 0)
+ {
+ fprintf(stderr,"Can't Purge\n");
+ return 1;
+ }
+
/*
* Set up all transfers
*/
--
1.7.1
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|