? libgpio/build ? libgpio/ieee1394/Makefile.in ? libgpio/include/Makefile.in ? libgpio/libgpio/Makefile.in ? libgpio/network/Makefile.in ? libgpio/parallel/Makefile.in ? libgpio/serial/Makefile.in ? libgpio/usb/Makefile.in Index: libgpio/.cvsignore =================================================================== RCS file: /cvsroot/gphoto/libgpio/.cvsignore,v retrieving revision 1.3 diff -u -r1.3 .cvsignore --- libgpio/.cvsignore 2000/07/21 18:56:24 1.3 +++ libgpio/.cvsignore 2000/08/05 09:38:42 @@ -25,3 +25,5 @@ gpio-usb.lo gpioConf.sh libgpio.la +Makefile +Makefile.in Index: libgpio/configure.in =================================================================== RCS file: /cvsroot/gphoto/libgpio/configure.in,v retrieving revision 1.7 diff -u -r1.7 configure.in --- libgpio/configure.in 2000/07/31 23:41:26 1.7 +++ libgpio/configure.in 2000/08/05 09:38:42 @@ -63,8 +63,8 @@ AC_PATH_PROG(LIBUSB_CONFIG,libusb-config) if test -n "${LIBUSB_CONFIG}"; then IOLIB_SUBDIRS="$IOLIB_SUBDIRS usb" - IOLIB_LDFLAGS="$IOLIB_LDFLAGS -Lusb -lgpio_usb" - IOLIB_CFLAGS="$IOLIB_CFLAGS -DGPIO_USB" + IOLIB_LDFLAGS="$IOLIB_LDFLAGS `libusb-config --libs` -lgpio_usb" + IOLIB_CFLAGS="$IOLIB_CFLAGS -DGPIO_USB `libusb-config --cflags`" else AC_MSG_WARN([ Index: libgpio/include/gpio.h =================================================================== RCS file: /cvsroot/gphoto/libgpio/include/gpio.h,v retrieving revision 1.1 diff -u -r1.1 gpio.h --- libgpio/include/gpio.h 2000/07/31 23:41:26 1.1 +++ libgpio/include/gpio.h 2000/08/05 09:38:42 @@ -89,6 +89,13 @@ } gpio_device_settings; +#ifdef GPIO_USB +enum { + GPIO_USB_IN_ENDPOINT, + GPIO_USB_OUT_ENDPOINT +}; +#endif + struct gpio_device; typedef struct gpio_device gpio_device; @@ -108,7 +115,7 @@ #ifdef GPIO_USB /* for USB devices */ int (*find_device)(gpio_device * dev, int idvendor, int idproduct); - int (*clear_halt) (gpio_device * dev); + int (*clear_halt) (gpio_device * dev, int ep); int (*msg_write) (gpio_device * dev, int value, char *bytes, int size); int (*msg_read) (gpio_device * dev, int value, char *bytes, int size); #endif @@ -241,6 +248,12 @@ successful: number of bytes read unsuccessful: GPIO_ERROR */ + int gpio_update (gpio_device *dev); + /* Updates the settings by closing/reopening the device + return values: + successful: GPIO_OK + unsuccessful: GPIO_ERROR + */ /* Serial and Parallel specific functions @@ -272,7 +285,7 @@ #ifdef GPIO_USB /* must port libusb to other platforms for this to drop-in */ int gpio_usb_find_device (gpio_device * dev, int idvendor, int idproduct); - int gpio_usb_clear_halt (gpio_device * dev); + int gpio_usb_clear_halt (gpio_device * dev, int ep); int gpio_usb_msg_write (gpio_device * dev, int value, char *bytes, int size); int gpio_usb_msg_read (gpio_device * dev, int value, char *bytes, int size); #endif Index: libgpio/libgpio/gpio.c =================================================================== RCS file: /cvsroot/gphoto/libgpio/libgpio/gpio.c,v retrieving revision 1.3 diff -u -r1.3 gpio.c --- libgpio/libgpio/gpio.c 2000/08/03 18:37:18 1.3 +++ libgpio/libgpio/gpio.c 2000/08/05 09:38:42 @@ -236,6 +236,11 @@ return GPIO_OK; } +int gpio_update(gpio_device *dev) +{ + return dev->ops->update(dev); +} + /* Serial and Parallel-specific functions */ /* ------------------------------------------------------------------ */ @@ -268,12 +273,12 @@ return (dev->ops->find_device(dev, idvendor, idproduct)); } -int gpio_usb_clear_halt (gpio_device * dev) +int gpio_usb_clear_halt (gpio_device * dev, int ep) { if (!dev->ops->clear_halt) return (GPIO_ERROR); - return (dev->ops->clear_halt(dev)); + return (dev->ops->clear_halt(dev, ep)); } int gpio_usb_msg_write (gpio_device * dev, int value, char *bytes, int size) Index: libgpio/libgpio/library.c =================================================================== RCS file: /cvsroot/gphoto/libgpio/libgpio/library.c,v retrieving revision 1.5 diff -u -r1.5 library.c --- libgpio/libgpio/library.c 2000/08/03 19:18:06 1.5 +++ libgpio/libgpio/library.c 2000/08/05 09:38:42 @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "gpio.h" #include "library.h" Index: libgpio/serial/unix.c =================================================================== RCS file: /cvsroot/gphoto/libgpio/serial/unix.c,v retrieving revision 1.2 diff -u -r1.2 unix.c --- libgpio/serial/unix.c 2000/08/03 18:34:32 1.2 +++ libgpio/serial/unix.c 2000/08/05 09:38:42 @@ -56,6 +56,8 @@ static struct sgttyb term_old; #endif +extern int device_debug; + /* Serial prototypes ------------------------------------------------------------------ */ int gpio_serial_init(gpio_device *dev); @@ -154,6 +156,7 @@ ------------------------------------------------------------------ */ int gpio_serial_init (gpio_device *dev) { + gpio_debug_printf("gpio_serial_init() called\n"); /* save previous setttings in to dev->settings_saved */ #if HAVE_TERMIOS_H if (tcgetattr(dev->device_fd, &term_old) < 0) { @@ -170,11 +173,11 @@ } int gpio_serial_exit (gpio_device *dev) { - } int gpio_serial_open(gpio_device * dev) { + gpio_debug_printf("gpio_serial_open() called\n"); #ifdef __FreeBSD__ dev->device_fd = open(dev->settings.serial.port, O_RDWR | O_NOCTTY | O_NONBLOCK); @@ -195,6 +198,7 @@ int gpio_serial_close(gpio_device * dev) { + gpio_debug_printf("gpio_serial_close() called\n"); if (close(dev->device_fd) == -1) { perror("gpio_serial_close: tried closing device file descriptor"); return GPIO_ERROR; @@ -205,6 +209,14 @@ int gpio_serial_write(gpio_device * dev, char *bytes, int size) { int len, ret; + int i; + + if (device_debug) { + gpio_debug_printf("gpio_serial_write(): "); + for (i = 0; i < size; i++) + gpio_debug_printf("%02x ", (unsigned char)bytes[i]); + gpio_debug_printf("\n"); + } len = 0; while (len < size) { /* Make sure we write all data while handling */ @@ -274,6 +286,14 @@ return GPIO_ERROR; } } + if (device_debug) { + int i; + + gpio_debug_printf("gpio_serial_read(timeout=%d): ",dev->timeout); + for (i = 0; i < readen; i++) + gpio_debug_printf("%02x ", (unsigned char)(bytes[i])); + gpio_debug_printf("\n"); + } return readen; } @@ -325,29 +345,38 @@ { int bit,request; + gpio_debug_printf("gpio_serial_set_pin(): "); + switch(pin) { case PIN_RTS: + gpio_debug_printf("pin=PIN_RTS "); bit = TIOCM_RTS; break; case PIN_DTR: + gpio_debug_printf("pin=PIN_DTR "); bit = TIOCM_DTR; break; case PIN_CTS: + gpio_debug_printf("pin=PIN_CTS "); bit = TIOCM_CTS; break; case PIN_DSR: + gpio_debug_printf("pin=PIN_DSR "); bit = TIOCM_DSR; break; case PIN_CD: + gpio_debug_printf("pin=PIN_CD "); bit = TIOCM_CD; break; case PIN_RING: + gpio_debug_printf("pin=PIN_RING "); bit = TIOCM_RNG; break; default: return GPIO_ERROR; } + gpio_debug_printf("level=%d\n", level); switch(level) { case 0: request = TIOCMBIS; @@ -373,6 +402,7 @@ */ int gpio_serial_update(gpio_device * dev) { + gpio_debug_printf("gpio_serial_update() called\n"); memcpy(&dev->settings, &dev->settings_pending, sizeof(dev->settings)); if (dev->device_fd != 0) { @@ -397,6 +427,8 @@ #if HAVE_TERMIOS_H struct termios tio; + gpio_debug_printf("gpio_serial_set_baudrate(speed=%d) called\n", + dev->settings.serial.speed); if (tcgetattr(dev->device_fd, &tio) < 0) { perror("tcgetattr"); return GPIO_ERROR; @@ -435,6 +467,8 @@ #else struct sgttyb ttyb; + gpio_debug_printf("gpio_serial_set_baudrate(speed=%d) called\n", + dev->settings.serial.speed); if (ioctl(dev->device_fd, TIOCGETP, &ttyb) < 0) { perror("ioctl(TIOCGETP)"); return GPIO_ERROR; Index: libgpio/usb/libusb.c =================================================================== RCS file: /cvsroot/gphoto/libgpio/usb/libusb.c,v retrieving revision 1.1 diff -u -r1.1 libusb.c --- libgpio/usb/libusb.c 2000/07/31 23:41:29 1.1 +++ libgpio/usb/libusb.c 2000/08/05 09:38:42 @@ -31,7 +31,7 @@ #include #include "gpio.h" -#undef GPIO_USB_DEBUG +extern int device_debug; int gpio_usb_list(gpio_device_info *list, int *count); int gpio_usb_init(gpio_device *dev); @@ -45,7 +45,7 @@ int gpio_usb_set_pin(gpio_device * dev, int pin, int level); int gpio_usb_update(gpio_device * dev); -int gpio_usb_clear_halt_lib(gpio_device * dev); +int gpio_usb_clear_halt_lib(gpio_device * dev, int ep); int gpio_usb_msg_read_lib(gpio_device * dev, int value, char *bytes, int size); int gpio_usb_msg_write_lib(gpio_device * dev, int value, char *bytes, int size); int gpio_usb_find_device_lib(gpio_device *dev, int idvendor, int idproduct); @@ -85,6 +85,8 @@ usb_find_busses(); usb_find_devices(); + gpio_debug_printf ("gpio_library_list() : &usb_busses=%x\n",&usb_busses); + gpio_debug_printf ("gpio_library_list() : usb_busses=%x\n",usb_busses); list[*count].type = GPIO_DEVICE_USB; strcpy(list[*count].name, "Universal Serial Bus"); strcpy(list[*count].path, "usb"); @@ -106,9 +108,7 @@ { int ret; -#ifdef GPIO_USB_DEBUG - printf ("gpio_usb_open() called\n"); -#endif + gpio_debug_printf ("gpio_usb_open() called\n"); dev->device_handle = usb_open(dev->usb_device); if (!dev->device_handle) return GPIO_ERROR; @@ -142,9 +142,7 @@ { int ret; -#ifdef GPIO_USB_DEBUG - printf ("gpio_usb_close() called\n"); -#endif + gpio_debug_printf ("gpio_usb_close() called\n"); if (usb_close(dev->device_handle) < 0) fprintf(stderr, "gpio_usb_close: %s\n", strerror(errno)); @@ -160,25 +158,34 @@ return gpio_usb_open(dev); } -int gpio_usb_clear_halt_lib(gpio_device * dev) +int gpio_usb_clear_halt_lib(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)) - return GPIO_ERROR; - else - return GPIO_OK; + int ret=0; + + switch (ep) { + case GPIO_USB_IN_ENDPOINT : + ret=usb_clear_halt(dev->device_handle, dev->settings.usb.inep); + break; + case GPIO_USB_OUT_ENDPOINT : + 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; + } + return (ret ? GPIO_ERROR : GPIO_OK); } int gpio_usb_write(gpio_device * dev, char *bytes, int size) { int i; -#ifdef GPIO_USB_DEBUG - printf("gpio_usb_write(): "); - for (i = 0; i < size; i++) - printf("%02x ",(unsigned char)bytes[i]); - printf("\n"); -#endif + if (device_debug) { + gpio_debug_printf("gpio_usb_write(): "); + for (i = 0; i < size; i++) + gpio_debug_printf("%02x ",(unsigned char)bytes[i]); + gpio_debug_printf("\n"); + } return usb_bulk_write(dev->device_handle, dev->settings.usb.outep, bytes, size, dev->timeout); } @@ -192,12 +199,12 @@ if (ret < 0) return GPIO_ERROR; -#ifdef GPIO_USB_DEBUG - printf("gpio_usb_read(timeout=%d): ", dev->timeout); - for (i = 0; i < ret; i++) - printf("%02x ",(unsigned char)(bytes[i])); - printf("\n"); -#endif + if (device_debug) { + printf("gpio_usb_read(timeout=%d): ", dev->timeout); + for (i = 0; i < ret; i++) + printf("%02x ",(unsigned char)(bytes[i])); + printf("\n"); + } return ret; } @@ -231,6 +238,11 @@ struct usb_bus *bus; struct usb_device *dev; + usb_init(); + usb_find_busses(); + usb_find_devices(); + gpio_debug_printf ("gpio_usb_find_device_lib() : &usb_busses=%x\n",&usb_busses); + gpio_debug_printf ("gpio_usb_find_device_lib() : usb_busses=%x\n",usb_busses); for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if ((dev->descriptor.idVendor == idvendor) &&