Thread: [Libphidget-cvs-commits] CVS: libphidget/src/libphidget phidget.c,1.11,1.12 phidget.h,1.7,1.8
Status: Alpha
Brought to you by:
jstrohm
From: Jack S. <js...@us...> - 2002-12-13 16:43:12
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory sc8-pr-cvs1:/tmp/cvs-serv15013/libphidget Modified Files: phidget.c phidget.h Log Message: I think I figured out how to not use the HID at all. Removing what I added yesterday to start supporting HID. Index: phidget.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** phidget.c 13 Dec 2002 05:15:13 -0000 1.11 --- phidget.c 13 Dec 2002 16:42:21 -0000 1.12 *************** *** 13,16 **** --- 13,17 ---- #include "phidget.h" #include <signal.h> + #include <dirent.h> #include "SoftPhidget.h" *************** *** 60,64 **** int productID; /**< USB Product ID. See the USB specification for more information. */ enum EDeviceClass deviceClass; /**< Device class */ - enum EStyle style; /**< Style of device, libusb or HID, hope to get away from HID totally */ }; --- 61,64 ---- *************** *** 73,94 **** const struct phidget_type *type; ! /** Union to handle the two different ways to access phidgets */ ! union ! { ! struct ! { ! /** libusb handle to the phidget, try not to use this if at all possible. ! * If this is NULL, the device isn't opened. */ ! struct usb_dev_handle *handle; ! /** libusb device to the phidget, try not to use this if at all possible */ ! struct usb_device *device; ! } libusb; ! struct ! { ! int handle; ! char *path; ! } HID; ! } handle; /** The serial number of the phidget for unique identificatoin */ --- 73,82 ---- const struct phidget_type *type; ! /** libusb handle to the phidget, try not to use this if at all possible. ! * If this is NULL, the device isn't opened. */ ! struct usb_dev_handle *handle; ! /** libusb device to the phidget, try not to use this if at all possible */ ! struct usb_device *device; /** The serial number of the phidget for unique identificatoin */ *************** *** 403,407 **** * Private function to register a new device type */ ! void _registerDeviceType(const char *name, int vendorID, int productID, int deviceClass, enum EStyle style) { int len; --- 391,395 ---- * Private function to register a new device type */ ! void _registerDeviceType(const char *name, int vendorID, int productID, int deviceClass) { int len; *************** *** 414,418 **** _typeList[_typeCount].productID = productID; _typeList[_typeCount].deviceClass = deviceClass; - _typeList[_typeCount].style = style; len = strlen(name); --- 402,405 ---- *************** *** 459,463 **** { // Close any devices that are open ! if (_usbDeviceList[t]->handle.libusb.handle != NULL) phidgetClose(_usbDeviceList[t]); } --- 446,450 ---- { // Close any devices that are open ! if (_usbDeviceList[t]->handle != NULL) phidgetClose(_usbDeviceList[t]); } *************** *** 568,573 **** temp->type = ptd; ! temp->handle.libusb.handle = NULL; ! temp->handle.libusb.device = device; temp->serial = _serial; temp->wasAttached = 0; --- 555,560 ---- temp->type = ptd; ! temp->handle = NULL; ! temp->device = device; temp->serial = _serial; temp->wasAttached = 0; *************** *** 794,798 **** for (t=0;t<_phidgetDeviceCount;t++) { ! if ( _usbDeviceList[t]->handle.libusb.device == dev) { // We found this device --- 781,785 ---- for (t=0;t<_phidgetDeviceCount;t++) { ! if ( _usbDeviceList[t]->device == dev) { // We found this device *************** *** 824,828 **** if ( _usbDeviceList[t]->serial==serial) { ! _usbDeviceList[t]->handle.libusb.device=dev; // It has changed // We found this device --- 811,815 ---- if ( _usbDeviceList[t]->serial==serial) { ! _usbDeviceList[t]->device=dev; // It has changed // We found this device *************** *** 862,867 **** if (_usbDeviceList[t]->openedState == WAS_OPENED) { ! usb_release_interface(_usbDeviceList[t]->handle.libusb.handle, 0); ! usb_close(_usbDeviceList[t]->handle.libusb.handle); _usbDeviceList[t]->openedState = WAS_OPENED; } --- 849,854 ---- if (_usbDeviceList[t]->openedState == WAS_OPENED) { ! usb_release_interface(_usbDeviceList[t]->handle, 0); ! usb_close(_usbDeviceList[t]->handle); _usbDeviceList[t]->openedState = WAS_OPENED; } *************** *** 878,882 **** { _usbDeviceList[t]->openedState = WAS_CLOSED; ! _usbDeviceList[t]->handle.libusb.handle = NULL; phidgetOpen(_usbDeviceList[t]); } --- 865,869 ---- { _usbDeviceList[t]->openedState = WAS_CLOSED; ! _usbDeviceList[t]->handle = NULL; phidgetOpen(_usbDeviceList[t]); } *************** *** 897,900 **** --- 884,890 ---- + /** + * Used to initialize the phidget library + */ enum ELPError phidgetInit(int catch_signals) { *************** *** 909,917 **** _clearDeviceTypes(); ! _registerDeviceType("QuadServo .1 Degree", 0x06C2, 0x0038, LP_SERVO_CONTROLLER, LIBUSB); ! _registerDeviceType("UniServo .1 Degree", 0x06C2, 0x0039, LP_SERVO_CONTROLLER, LIBUSB); ! _registerDeviceType("Interface Kit 884", 0x0925, 0x8201, LP_INTERFACE_KIT, HID); ! _registerDeviceType("Interface Kit 884", 0x06C2, 0x0040, LP_INTERFACE_KIT, HID); ! _registerDeviceType("Interface Kit 088", 0x06C2, 0x0041, LP_INTERFACE_KIT, HID); //_registerDeviceType("RFID VID/PID", 0x06C2, 0x0030, LP_OTHER); //_registerDeviceType("8-AdvancedServo", 0x06C2, 0x003B, LP_SERVO_CONTROLLER); --- 899,907 ---- _clearDeviceTypes(); ! _registerDeviceType("QuadServo .1 Degree", 0x06C2, 0x0038, LP_SERVO_CONTROLLER); ! _registerDeviceType("UniServo .1 Degree", 0x06C2, 0x0039, LP_SERVO_CONTROLLER); ! _registerDeviceType("Interface Kit 884", 0x0925, 0x8201, LP_INTERFACE_KIT); ! _registerDeviceType("Interface Kit 884", 0x06C2, 0x0040, LP_INTERFACE_KIT); ! _registerDeviceType("Interface Kit 088", 0x06C2, 0x0041, LP_INTERFACE_KIT); //_registerDeviceType("RFID VID/PID", 0x06C2, 0x0030, LP_OTHER); //_registerDeviceType("8-AdvancedServo", 0x06C2, 0x003B, LP_SERVO_CONTROLLER); *************** *** 1042,1046 **** ! if (phidgetDevice->handle.libusb.handle != NULL) { phidgetDevice->openedState = WAS_ERROR; --- 1032,1036 ---- ! if (phidgetDevice->handle != NULL) { phidgetDevice->openedState = WAS_ERROR; *************** *** 1056,1083 **** } ! phidgetDevice->handle.libusb.handle = usb_open(phidgetDevice->handle.libusb.device); ! if (phidgetDevice->handle.libusb.handle) { ! while (usb_set_configuration(phidgetDevice->handle.libusb.handle, 1)<0); ! /* ! ret = usb_set_configuration(phidgetDevice->handle.libusb.handle, 1); ! if (ret < 0) { printf("Can't set configuration:%d\n",ret); ! usb_close(phidgetDevice->handle.libusb.handle); ! phidgetDevice->handle.libusb.handle = NULL; ! phidgetDevice->openedState = WAS_ERROR; ! _error(LPE_SET_CONFIGURATION_FAILED); ! return NULL; } - */ ! ret = usb_claim_interface(phidgetDevice->handle.libusb.handle, 0); if (ret < 0) { ! usb_close(phidgetDevice->handle.libusb.handle); ! phidgetDevice->handle.libusb.handle = NULL; phidgetDevice->openedState = WAS_ERROR; _error(LPE_CLAIM_INTERFACE_FAILED); --- 1046,1072 ---- } ! phidgetDevice->handle = usb_open(phidgetDevice->device); ! if (phidgetDevice->handle) { ! //while (usb_set_configuration(phidgetDevice->handle, 1)<0); ! ret = usb_set_configuration(phidgetDevice->handle, 1); ! if (ret < 0) ! { printf("Can't set configuration:%d\n",ret); ! usb_close(phidgetDevice->handle); ! phidgetDevice->handle = NULL; ! phidgetDevice->openedState = WAS_ERROR; ! _error(LPE_SET_CONFIGURATION_FAILED); ! return NULL; } ! ret = usb_claim_interface(phidgetDevice->handle, 0); if (ret < 0) { ! usb_close(phidgetDevice->handle); ! phidgetDevice->handle = NULL; phidgetDevice->openedState = WAS_ERROR; _error(LPE_CLAIM_INTERFACE_FAILED); *************** *** 1085,1094 **** } ! ret = usb_set_altinterface(phidgetDevice->handle.libusb.handle, 0); if (ret < 0) { ! usb_release_interface(phidgetDevice->handle.libusb.handle, 0); ! usb_close(phidgetDevice->handle.libusb.handle); ! phidgetDevice->handle.libusb.handle = NULL; phidgetDevice->openedState = WAS_ERROR; _error(LPE_SET_ALT_INTERFACE_FAILED); --- 1074,1083 ---- } ! ret = usb_set_altinterface(phidgetDevice->handle, 0); if (ret < 0) { ! usb_release_interface(phidgetDevice->handle, 0); ! usb_close(phidgetDevice->handle); ! phidgetDevice->handle = NULL; phidgetDevice->openedState = WAS_ERROR; _error(LPE_SET_ALT_INTERFACE_FAILED); *************** *** 1136,1140 **** ! if (phidgetDevice->handle.libusb.handle) { if (phidgetDevice->type->deviceClass == LP_SERVO_CONTROLLER) --- 1125,1129 ---- ! if (phidgetDevice->handle) { if (phidgetDevice->type->deviceClass == LP_SERVO_CONTROLLER) *************** *** 1154,1160 **** } ! usb_release_interface(phidgetDevice->handle.libusb.handle, 0); ! usb_close(phidgetDevice->handle.libusb.handle); ! phidgetDevice->handle.libusb.handle = NULL; phidgetDevice->openedState = WAS_CLOSED; } else --- 1143,1149 ---- } ! usb_release_interface(phidgetDevice->handle, 0); ! usb_close(phidgetDevice->handle); ! phidgetDevice->handle = NULL; phidgetDevice->openedState = WAS_CLOSED; } else *************** *** 1180,1187 **** if (phidgetDevice->attached == 0) return (_error(LPE_PHIDGET_NOT_ATTACHED)); ! if (phidgetDevice->handle.libusb.handle == NULL) return (_error(LPE_PHIDGET_NOT_OPENED)); ! ret=usb_control_msg(phidgetDevice->handle.libusb.handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); if (ret!=size) return (_error(LPE_CONTROL_MSG_ERROR)); --- 1169,1176 ---- if (phidgetDevice->attached == 0) return (_error(LPE_PHIDGET_NOT_ATTACHED)); ! if (phidgetDevice->handle == NULL) return (_error(LPE_PHIDGET_NOT_OPENED)); ! ret=usb_control_msg(phidgetDevice->handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); if (ret!=size) return (_error(LPE_CONTROL_MSG_ERROR)); *************** *** 1206,1213 **** return (_error(LPE_PHIDGET_NOT_ATTACHED)); ! if (phidgetDevice->handle.libusb.handle == NULL) return (_error(LPE_PHIDGET_NOT_OPENED)); ! if (usb_bulk_read(phidgetDevice->handle.libusb.handle, 0x01, buffer, size, 5000) != 0) return (_error(LPE_BULK_READ_ERROR)); --- 1195,1202 ---- return (_error(LPE_PHIDGET_NOT_ATTACHED)); ! if (phidgetDevice->handle == NULL) return (_error(LPE_PHIDGET_NOT_OPENED)); ! if (usb_bulk_read(phidgetDevice->handle, 0x01, buffer, size, 5000) != 0) return (_error(LPE_BULK_READ_ERROR)); Index: phidget.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** phidget.h 13 Dec 2002 05:15:13 -0000 1.7 --- phidget.h 13 Dec 2002 16:42:30 -0000 1.8 *************** *** 106,119 **** }; - /** - * Style of device, libusb or HID, hope to get away from HID totally - */ - enum EStyle - { - LIBUSB=0, /**< This device uses libusb */ - HID=1 /**< This device uses HID driver */ - }; - - #ifdef __cplusplus extern "C" --- 106,109 ---- |