? build
Index: .cvsignore
===================================================================
RCS file: /cvs/gnome/libgpio/.cvsignore,v
retrieving revision 1.1
diff -u -r1.1 .cvsignore
--- .cvsignore	2000/06/11 17:33:57	1.1
+++ .cvsignore	2000/07/20 22:24:00
@@ -21,3 +21,5 @@
 gpio-usb.lo
 gpioConf.sh
 libgpio.la
+Makefile
+Makefile.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgpio/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog	2000/07/15 18:59:16	1.3
+++ ChangeLog	2000/07/20 22:24:00
@@ -1,3 +1,9 @@
+2000-07-20  Fabrice Bellet  <Fabrice.Bellet@creatis.insa-lyon.fr>
+
+	* .cvsignore : added Makefile and Makefile.in
+	* gpio-usb.[hc] : changed gpio_usb_clear_halt() so we
+	  can choose which endpoint to reset.
+
 2000-07-15  Fabrice Bellet  <Fabrice.Bellet@creatis.insa-lyon.fr>
 
 	* gpio-usb.c : removed useless call to usb_release_interface()
Index: gpio-ieee1394.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-ieee1394.c,v
retrieving revision 1.6
diff -u -r1.6 gpio-ieee1394.c
--- gpio-ieee1394.c	2000/06/26 22:14:17	1.6
+++ gpio-ieee1394.c	2000/07/20 22:24:00
@@ -40,6 +40,10 @@
 
 int 		gpio_ieee1394_update (gpio_device *dev);
 
+int		gpio_ieee1394_clear_halt (gpio_device *dev);
+
+/* private */
+
 int 		gpio_ieee1394_set_baudrate(gpio_device *dev);
 
 
@@ -53,8 +57,9 @@
         gpio_ieee1394_read,
         gpio_ieee1394_write,
         gpio_ieee1394_get_pin,
-		gpio_iee1394_set_pin,
-        gpio_ieee1394_update
+	gpio_iee1394_set_pin,
+        gpio_ieee1394_update,
+	gpio_ieee1394_clear_halt
 };
 
 /* IEEE1394 API functions
@@ -104,4 +109,13 @@
 
 int gpio_ieee1394_update (gpio_device *dev) {
 
+}
+
+/*
+ * This function does nothing with IEEE1394
+ *
+ */
+
+int gpio_ieee1394_clear_halt (gpio_device *dev, int ep) {
+	return GPIO_OK;
 }
Index: gpio-network.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-network.c,v
retrieving revision 1.1
diff -u -r1.1 gpio-network.c
--- gpio-network.c	2000/07/13 22:40:34	1.1
+++ gpio-network.c	2000/07/20 22:24:00
@@ -20,6 +20,7 @@
    Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
 #include "gpio.h"
 
 /* network prototypes
@@ -40,6 +41,10 @@
 
 int 		gpio_network_update (gpio_device *dev);
 
+int		gpio_network_clear_halt (gpio_device *dev, int ep);
+
+/* private */
+
 int 		gpio_network_set_baudrate(gpio_device *dev);
 
 struct gpio_operations gpio_network_operations =
@@ -53,7 +58,8 @@
         gpio_network_write,
         gpio_network_get_pin,
 	gpio_network_set_pin,
-        gpio_network_update
+        gpio_network_update,
+	gpio_network_clear_halt
 };
 
 
@@ -104,4 +110,13 @@
 
 int gpio_network_update (gpio_device *dev) {
 
+}
+
+/*
+ * This function does nothing for network
+ *
+ */
+
+int gpio_network_clear_halt (gpio_device *dev, int ep) {
+	return GPIO_OK;
 }
Index: gpio-parallel.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-parallel.c,v
retrieving revision 1.7
diff -u -r1.7 gpio-parallel.c
--- gpio-parallel.c	2000/07/17 17:25:24	1.7
+++ gpio-parallel.c	2000/07/20 22:24:00
@@ -51,6 +51,10 @@
 
 int 		gpio_parallel_update (gpio_device *dev);
 
+int		gpio_parallel_clear_halt (gpio_device *dev, int ep);
+
+/* private */
+
 int 		gpio_parallel_set_baudrate(gpio_device *dev);
 
 struct gpio_operations gpio_parallel_operations =
@@ -64,7 +68,8 @@
         gpio_parallel_write,
         gpio_parallel_get_pin,
 	gpio_parallel_set_pin,
-        gpio_parallel_update
+        gpio_parallel_update,
+	gpio_parallel_clear_halt
 };
 
 
@@ -134,4 +139,12 @@
 
 int gpio_parallel_update (gpio_device *dev) {
 
+}
+
+/*
+ * This function does nothing for parallel
+ *
+ */
+int gpio_parallel_clear_halt (gpio_device *dev, int ep) {
+	return GPIO_OK;
 }
Index: gpio-serial.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-serial.c,v
retrieving revision 1.9
diff -u -r1.9 gpio-serial.c
--- gpio-serial.c	2000/07/17 17:25:24	1.9
+++ gpio-serial.c	2000/07/20 22:24:01
@@ -49,6 +49,8 @@
 
 #include "gpio.h"
 
+#define	GPIO_SERIAL_DEBUG 1
+
 #ifdef HAVE_TERMIOS_H
 static struct termios term_old;
 #else
@@ -68,11 +70,13 @@
 int 		gpio_serial_read(gpio_device *dev, char *bytes, int size);
 int 		gpio_serial_write(gpio_device *dev, char *bytes, int size);
 
-int			gpio_serial_get_pin(gpio_device *dev, int pin);
+int		gpio_serial_get_pin(gpio_device *dev, int pin);
 int     	gpio_serial_set_pin(gpio_device *dev, int pin, int level); 
 
 int 		gpio_serial_update (gpio_device *dev);
 
+int		gpio_serial_clear_halt(gpio_device *dev, int ep);
+
 /* private */
 int 		gpio_serial_set_baudrate(gpio_device *dev);
 static speed_t 	gpio_serial_baudconv(int rate);
@@ -88,7 +92,8 @@
 	gpio_serial_write,
 	gpio_serial_get_pin,
 	gpio_serial_set_pin,
-	gpio_serial_update
+	gpio_serial_update,
+	gpio_serial_clear_halt
 };
 
 /* Serial API functions
@@ -134,6 +139,9 @@
 }
 
 int gpio_serial_init (gpio_device *dev) {
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_init() called\n");
+#endif
 	/* save previous setttings in to dev->settings_saved */
 #if HAVE_TERMIOS_H
 	if (tcgetattr(dev->device_fd, &term_old) < 0) {
@@ -150,11 +158,13 @@
 }
 
 int gpio_serial_exit (gpio_device *dev) {
-
 }
 
 int gpio_serial_open(gpio_device * dev)
 {
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_open() called\n");
+#endif
 
 #ifdef __FreeBSD__
 	dev->device_fd = open(dev->settings.serial.port, O_RDWR | O_NOCTTY | O_NONBLOCK);
@@ -175,6 +185,9 @@
 
 int gpio_serial_close(gpio_device * dev)
 {
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_close() called\n");
+#endif
 	if (close(dev->device_fd) == -1) {
 		perror("gpio_serial_close: tried closing device file descriptor");
 		return GPIO_ERROR;
@@ -185,6 +198,14 @@
 int gpio_serial_write(gpio_device * dev, char *bytes, int size)
 {
 	int len, ret;
+#ifdef GPIO_SERIAL_DEBUG
+	int i;
+
+	printf ("gpio_serial_write(): ");
+	for (i=0;i<size;i++)
+	  printf ("%02x ",(unsigned char)bytes[i]);
+	printf("\n");
+#endif
 
 	len = 0;
 	while (len < size) {	/* Make sure we write all data while handling */
@@ -254,6 +275,16 @@
 			return GPIO_ERROR;
 		}
 	}
+#ifdef GPIO_SERIAL_DEBUG
+	{
+		int i;
+
+		printf ("gpio_serial_read(timeout=%d): ",dev->timeout);
+		for (i=0;i<readen;i++)
+		  printf ("%02x ",(unsigned char)(bytes[i]));
+		printf("\n");
+	}
+#endif
 	return readen;
 }
 
@@ -305,29 +336,54 @@
 {
 	int bit,request;
 
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_set_pin(): ");
+#endif
+
 	switch(pin) {
 		case PIN_RTS:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_RTS ");
+#endif
 			bit = TIOCM_RTS;
 			break;
 		case PIN_DTR:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_DTR ");
+#endif
 			bit = TIOCM_DTR;
 			break;
 		case PIN_CTS:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_CTS ");
+#endif
 			bit = TIOCM_CTS;
 			break;
 		case PIN_DSR:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_DSR ");
+#endif
 			bit = TIOCM_DSR;
 			break;
 		case PIN_CD:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_CD ");
+#endif
 			bit = TIOCM_CD;
 			break;
 		case PIN_RING:
+#ifdef GPIO_SERIAL_DEBUG
+			printf ("pin=PIN_RING ");
+#endif
 			bit = TIOCM_RNG;
 			break;
 		default:
 			return GPIO_ERROR;
 	}
 	
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("level=%d\n",level);
+#endif
 	switch(level) {
 		case 0:
 			request = TIOCMBIS;
@@ -353,6 +409,9 @@
  */
 int gpio_serial_update(gpio_device * dev)
 {
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_update() called\n");
+#endif
 	memcpy(&dev->settings, &dev->settings_pending, sizeof(dev->settings));
 
 	if (dev->device_fd != 0) {
@@ -367,6 +426,15 @@
 }
 
 /*
+ * This function does nothing for serial
+ *
+ */
+int gpio_serial_clear_halt(gpio_device * dev, int ep)
+{
+	return GPIO_OK;
+}
+
+/*
    Serial port specific helper functions
    ----------------------------------------------------------------
  */
@@ -377,6 +445,10 @@
 #if HAVE_TERMIOS_H
 	struct termios tio;
 
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_set_baudrate(speed=%d) called\n",
+		dev->settings.serial.speed);
+#endif
 	if (tcgetattr(dev->device_fd, &tio) < 0) {
 		perror("tcgetattr");
 		return GPIO_ERROR;
@@ -415,6 +487,10 @@
 #else
 	struct sgttyb ttyb;
 
+#ifdef GPIO_SERIAL_DEBUG
+	printf ("gpio_serial_set_baudrate(speed=%d) called\n",
+		dev->settings.serial.speed);
+#endif
 	if (ioctl(dev->device_fd, TIOCGETP, &ttyb) < 0) {
 		perror("ioctl(TIOCGETP)");
 		return GPIO_ERROR;
Index: gpio-usb.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-usb.c,v
retrieving revision 1.11
diff -u -r1.11 gpio-usb.c
--- gpio-usb.c	2000/07/15 18:59:16	1.11
+++ gpio-usb.c	2000/07/20 22:24:01
@@ -47,6 +47,9 @@
 
 int gpio_usb_init(gpio_device *dev)
 {
+#ifdef GPIO_USB_DEBUG
+	printf ("gpio_usb_init() called\n");
+#endif
 	usb_init();
         usb_find_busses();
         usb_find_devices();
@@ -114,19 +117,38 @@
 
 }
 
-int gpio_usb_clear_halt (gpio_device * dev)
+int gpio_usb_clear_halt (gpio_device * dev,int ep)
 {
-	if (usb_clear_halt (dev->device_handle, dev->settings.usb.inep)
-		|| usb_clear_halt (dev->device_handle, dev->settings.usb.outep))
+	int ret=0;
+
+#ifdef GPIO_USB_DEBUG
+	printf ("gpio_usb_clear_halt() called ");
+#endif
+	switch (ep) {
+	  case GPIO_USB_IN_ENDPOINT :
+#ifdef GPIO_USB_DEBUG
+		printf ("[ep=IN]\n");
+#endif
+		ret=usb_clear_halt (dev->device_handle,dev->settings.usb.inep);
+		break;
+	  case GPIO_USB_OUT_ENDPOINT :
+#ifdef GPIO_USB_DEBUG
+		printf ("[ep=OUT]\n");
+#endif
+		ret=usb_clear_halt (dev->device_handle,dev->settings.usb.outep);
+		break;
+	  default:
+	  	fprintf (stderr,"gpio_usb_clear_halt: bad EndPoint argument\n");
 		return GPIO_ERROR;
-	else
-		return GPIO_OK;
+	}
+	return (ret?GPIO_ERROR:GPIO_OK);
 }
 
 int gpio_usb_write(gpio_device * dev, char *bytes, int size)
 {
-	int i;
 #ifdef GPIO_USB_DEBUG
+	int i;
+
 	printf ("gpio_usb_write(): ");
 	for (i=0;i<size;i++)
 	  printf ("%02x ",(unsigned char)bytes[i]);
@@ -195,7 +217,8 @@
 	gpio_usb_write,
 	gpio_usb_get_pin,
 	gpio_usb_set_pin,
-	gpio_usb_update
+	gpio_usb_update,
+	gpio_usb_clear_halt
 };
 
 int gpio_usb_find_device(int idvendor, int idproduct, struct usb_device **device)
Index: gpio-usb.h
===================================================================
RCS file: /cvs/gnome/libgpio/gpio-usb.h,v
retrieving revision 1.2
diff -u -r1.2 gpio-usb.h
--- gpio-usb.h	2000/06/11 18:58:08	1.2
+++ gpio-usb.h	2000/07/20 22:24:01
@@ -13,4 +13,9 @@
 
 extern struct gpio_operations gpio_usb_operations;
 
+enum {
+	GPIO_USB_IN_ENDPOINT,
+	GPIO_USB_OUT_ENDPOINT
+};
+
 #endif /* _GPIO_USB_H_ */
Index: gpio.c
===================================================================
RCS file: /cvs/gnome/libgpio/gpio.c,v
retrieving revision 1.10
diff -u -r1.10 gpio.c
--- gpio.c	2000/07/13 22:40:34	1.10
+++ gpio.c	2000/07/20 22:24:01
@@ -243,6 +243,11 @@
 	/* Set the status of pin from dev to level */
 	return dev->ops->set_pin(dev, pin, level);
 }
+int gpio_clear_halt(gpio_device * dev, int ep)
+{
+	/* Reset an endpoint (USB only) */
+	return dev->ops->clear_halt(dev, ep);
+}
 int gpio_set_timeout(gpio_device * dev, int millisec_timeout)
 {
 	dev->timeout = millisec_timeout;
Index: gpio.h.in
===================================================================
RCS file: /cvs/gnome/libgpio/gpio.h.in,v
retrieving revision 1.15
diff -u -r1.15 gpio.h.in
--- gpio.h.in	2000/07/17 17:25:24	1.15
+++ gpio.h.in	2000/07/20 22:24:02
@@ -93,16 +93,17 @@
 struct gpio_device;
 typedef struct gpio_device gpio_device;
 struct gpio_operations {
-	int (*list)	(gpio_device_info *, int*);
-	int (*init)	(gpio_device *);
-	int (*exit)	(gpio_device *);
-	int (*open)	(gpio_device *);
-	int (*close)	(gpio_device *);
-	int (*read)	(gpio_device *, char *, int);
-	int (*write)	(gpio_device *, char *, int);
-	int (*get_pin)	(gpio_device *, int);
-	int (*set_pin)	(gpio_device *, int, int);
-	int (*update)   (gpio_device *);
+	int (*list)		(gpio_device_info *, int*);
+	int (*init)		(gpio_device *);
+	int (*exit)		(gpio_device *);
+	int (*open)		(gpio_device *);
+	int (*close)		(gpio_device *);
+	int (*read)		(gpio_device *, char *, int);
+	int (*write)		(gpio_device *, char *, int);
+	int (*get_pin)		(gpio_device *, int);
+	int (*set_pin)		(gpio_device *, int, int);
+	int (*update)   	(gpio_device *);
+	int (*clear_halt)	(gpio_device *, int);
 };
 
 /* Specify the device information */
@@ -232,7 +233,7 @@
 				unsuccessful: GPIO_ERROR
 		*/
 
-		int gpio_get_pin   (gpio_device *dev, int pin);
+	int gpio_get_pin   (gpio_device *dev, int pin);
 		/* Give the status of pin from dev
 			pin values:
 				 see PIN_ constants in the various .h files	
@@ -242,7 +243,7 @@
 		not implemented for USB (useful?)
 		*/
 
-		int gpio_set_pin   (gpio_device *dev, int pin, int level);
+	int gpio_set_pin   (gpio_device *dev, int pin, int level);
 		/* set the status of pin from dev to level
 			pin values:
 				 see PIN_ constants in the various .h files	
@@ -253,6 +254,16 @@
 				  successful: status
 				unsuccessful: GPIO_ERROR
 		not implemented for USB (useful?)
+		*/
+	int gpio_clear_halt (gpio_device *dev, int ep);
+		/* reset an endpoint on USB devices
+			ep value :
+				GPIO_USB_IN_ENDPOINT
+				GPIO_USB_OUT_ENDPOINT
+			return values:
+				successful: GPIO_OK
+				unsuccessful: GPIO_ERROR
+		only implemented (and useful) for USB
 		*/
 
 #endif /* _GPIO_H_ */
