diff -u --recursive --new-file libgpio.orig/.cvsignore libgpio/.cvsignore --- libgpio.orig/.cvsignore Fri Sep 15 14:53:50 2000 +++ libgpio/.cvsignore Fri Sep 15 15:04:34 2000 @@ -18,3 +18,5 @@ gpio_test gpioConf.sh libgpio.la +Makefile +Makefile.in diff -u --recursive --new-file libgpio.orig/configure.in libgpio/configure.in --- libgpio.orig/configure.in Tue Aug 1 01:41:26 2000 +++ libgpio/configure.in Fri Sep 15 15:04:34 2000 @@ -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([ diff -u --recursive --new-file libgpio.orig/include/gpio.h libgpio/include/gpio.h --- libgpio.orig/include/gpio.h Fri Sep 15 14:54:44 2000 +++ libgpio/include/gpio.h Fri Sep 15 15:04:34 2000 @@ -270,6 +270,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 diff -u --recursive --new-file libgpio.orig/libgpio/gpio.c libgpio/libgpio/gpio.c --- libgpio.orig/libgpio/gpio.c Fri Sep 15 14:54:44 2000 +++ libgpio/libgpio/gpio.c Fri Sep 15 15:04:34 2000 @@ -35,18 +35,16 @@ int device_count; /* Toggle to turn on/off debugging */ -int glob_debug_level=0; +int glob_debug_level=1; void gpio_debug_printf (int target_debug_level, int debug_level, char *format, ...) { va_list arg; if ((debug_level > 0)&&(debug_level >= target_debug_level)) { - fprintf(stderr, "gpio: "); va_start(arg, format); vfprintf(stderr, format, arg); va_end(arg); - fprintf(stderr, "\n"); } } @@ -315,6 +313,11 @@ gpio_debug_printf(GPIO_DEBUG_LOW, dev->debug_level, "gpio_get_settings: ok"); return GPIO_OK; +} + +int gpio_update(gpio_device *dev) +{ + return dev->ops->update(dev); } /* Serial and Parallel-specific functions */ diff -u --recursive --new-file libgpio.orig/libgpio/library.c libgpio/libgpio/library.c --- libgpio.orig/libgpio/library.c Fri Sep 15 14:53:50 2000 +++ libgpio/libgpio/library.c Fri Sep 15 15:04:34 2000 @@ -1,5 +1,6 @@ #include #include +#include #include "gpio.h" #include "library.h" @@ -15,11 +16,13 @@ if ((lh = GPIO_DLOPEN(filename))==NULL) { gpio_debug_printf(GPIO_DEBUG_LOW, glob_debug_level, - "%s is not a library (%s) ", filename, GPIO_DLERROR()); + "%s is not a library (%s)\n", + filename, GPIO_DLERROR()); return (GPIO_ERROR); } - gpio_debug_printf(GPIO_DEBUG_LOW, glob_debug_level, "%s is a library ", filename); + gpio_debug_printf(GPIO_DEBUG_LOW, glob_debug_level, "%s is a library\n", + filename); GPIO_DLCLOSE(lh); return (GPIO_OK); diff -u --recursive --new-file libgpio.orig/usb/libusb.c libgpio/usb/libusb.c --- libgpio.orig/usb/libusb.c Fri Sep 15 14:56:09 2000 +++ libgpio/usb/libusb.c Fri Sep 15 15:08:23 2000 @@ -31,7 +31,8 @@ #include #include "gpio.h" -#define GPIO_USB_DEBUG +extern int device_debug; +extern int glob_debug_level; int gpio_usb_list(gpio_device_info *list, int *count); int gpio_usb_init(gpio_device *dev); @@ -52,12 +53,14 @@ /* Dynamic library functions --------------------------------------------------------------------- */ -gpio_device_type gpio_library_type () { +gpio_device_type +gpio_library_type () { return (GPIO_DEVICE_USB); } -gpio_operations *gpio_library_operations () { +gpio_operations * +gpio_library_operations () { gpio_operations *ops; @@ -79,7 +82,8 @@ return (ops); } -int gpio_library_list(gpio_device_info *list, int *count) +int +gpio_library_list(gpio_device_info *list, int *count) { list[*count].type = GPIO_DEVICE_USB; @@ -91,7 +95,8 @@ return GPIO_OK; } -int gpio_usb_init(gpio_device *dev) +int +gpio_usb_init(gpio_device *dev) { usb_init(); usb_find_busses(); @@ -99,18 +104,17 @@ return (GPIO_OK); } -int gpio_usb_exit(gpio_device *dev) +int +gpio_usb_exit(gpio_device *dev) { return (GPIO_OK); } -int gpio_usb_open(gpio_device *dev) +int +gpio_usb_open(gpio_device *dev) { int ret; -#ifdef GPIO_USB_DEBUG - printf ("gpio_usb_open() called\n"); -#endif dev->device_handle = usb_open(dev->usb_device); if (!dev->device_handle) return GPIO_ERROR; @@ -140,13 +144,11 @@ return GPIO_OK; } -int gpio_usb_close(gpio_device *dev) +int +gpio_usb_close(gpio_device *dev) { int ret; -#ifdef GPIO_USB_DEBUG - printf ("gpio_usb_close() called\n"); -#endif if (usb_close(dev->device_handle) < 0) fprintf(stderr, "gpio_usb_close: %s\n", strerror(errno)); @@ -156,7 +158,8 @@ return GPIO_OK; } -int gpio_usb_reset(gpio_device *dev) +int +gpio_usb_reset(gpio_device *dev) { gpio_usb_close(dev); return gpio_usb_open(dev); @@ -203,49 +206,55 @@ bytes, size, dev->timeout); 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 return ret; } -int gpio_usb_msg_write_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 i; + return usb_control_msg(dev->device_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE, size > 1 ? 0x04 : 0x0c, value, 0, bytes, size, dev->timeout); } -int gpio_usb_msg_read_lib(gpio_device * dev, int value, char *bytes, int size) +int +gpio_usb_msg_read_lib(gpio_device * dev, int value, char *bytes, int size) { - return usb_control_msg(dev->device_handle, + int ret, i; + + ret = usb_control_msg(dev->device_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | 0x80, size > 1 ? 0x04 : 0x0c, value, 0, bytes, size, dev->timeout); + return ret; } /* * This function applys changes to the device * (At this time it does nothing) */ -int gpio_usb_update(gpio_device * dev) +int +gpio_usb_update(gpio_device * dev) { memcpy(&dev->settings, &dev->settings_pending, sizeof(dev->settings)); return GPIO_OK; } -int gpio_usb_find_device_lib(gpio_device * d, int idvendor, int idproduct) +int +gpio_usb_find_device_lib(gpio_device * d, int idvendor, int idproduct) { struct usb_bus *bus; struct usb_device *dev; -printf("here\n"); + + if (!usb_busses) { + usb_init(); + usb_find_busses(); + usb_find_devices(); + } for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { -printf("vendor=%x product=%x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); if ((dev->descriptor.idVendor == idvendor) && (dev->descriptor.idProduct == idproduct)) { d->usb_device = dev;