The branch, master has been updated
via 1c5fa36b67bc30742eee94ed3e3648fcd4640f24 (commit)
from cd2ead2f23cea38de6fdbf2459c79cb4936fbf8d (commit)
- Log -----------------------------------------------------------------
commit 1c5fa36b67bc30742eee94ed3e3648fcd4640f24
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Fri Oct 7 15:59:54 2011 +0200
Interface can not be changed on an already open device
Based upon code from Uwe Bonnes, improved by me.
-----------------------------------------------------------------------
Summary of changes:
src/ftdi.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/ftdi.c b/src/ftdi.c
index 1f45e95..59a9eea 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -149,12 +149,23 @@ struct ftdi_context *ftdi_new(void)
\retval 0: all fine
\retval -1: unknown interface
\retval -2: USB device unavailable
+ \retval -3: Device already open, interface can't be set in that state
*/
int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface
interface)
{
if (ftdi == NULL)
ftdi_error_return(-2, "USB device unavailable");
+ if (ftdi->usb_dev != NULL)
+ {
+ int check_interface = interface;
+ if (check_interface == INTERFACE_ANY)
+ check_interface = INTERFACE_A;
+
+ if (ftdi->index != check_interface)
+ ftdi_error_return(-3, "Interface can not be changed on an already
open device");
+ }
+
switch (interface)
{
case INTERFACE_ANY:
hooks/post-receive
--
A library to talk to FTDI chips
--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|