Update of /cvsroot/libphidget/libphidget/src/libphidget
In directory sc8-pr-cvs1:/tmp/cvs-serv21336/libphidget
Modified Files:
phidget.c phidget.h
Log Message:
hopefully added the reading of interface kit 880 and fixed a bug in the phidgetRead function
Index: phidget.c
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** phidget.c 13 Dec 2002 20:45:14 -0000 1.13
--- phidget.c 13 Dec 2002 21:16:23 -0000 1.14
***************
*** 1198,1202 ****
return (_error(LPE_PHIDGET_NOT_OPENED));
! if (usb_bulk_read(phidgetDevice->handle, 0x01, buffer, size, 5000) != 0)
return (_error(LPE_BULK_READ_ERROR));
--- 1198,1204 ----
return (_error(LPE_PHIDGET_NOT_OPENED));
! //if (usb_bulk_read(phidgetDevice->handle, 0x01, buffer, size, 5000) != 0)
! //return (_error(LPE_BULK_READ_ERROR));
! if (usb_bulk_read(phidgetDevice->handle, 0x01, buffer, size, 5000) != size)
return (_error(LPE_BULK_READ_ERROR));
***************
*** 1374,1382 ****
* Helper function to read from an interface kit.
*/
! void phidgetInterfaceKit488Read(struct phidget *phidgetDevice, float analog[4], int digital[8])
{
char buffer[7];
! phidgetRead(phidgetDevice,buffer,sizeof(buffer));
digital[0]=(buffer[0] & 1)==1;
--- 1376,1386 ----
* Helper function to read from an interface kit.
*/
! enum ELPError phidgetInterfaceKit488Read(struct phidget *phidgetDevice, float analog[4], int digital[8])
{
char buffer[7];
! enum ELPError err=phidgetRead(phidgetDevice,buffer,sizeof(buffer));
! if (err!=LPE_NONE)
! return(_error(err));
digital[0]=(buffer[0] & 1)==1;
***************
*** 1393,1396 ****
--- 1397,1446 ----
analog[2]=((unsigned char)buffer[6]+((unsigned char)buffer[5] & 0x0f) * 256);
analog[3]=((unsigned char)buffer[4]+((unsigned char)buffer[5] & 0xf0) * 16);
+
+ return (_error(LPE_NONE));
+ }
+
+ /**
+ * Helper function to read from an interface kit.
+ */
+ enum ELPError phidgetInterfaceKit880Read(struct phidget *phidgetDevice, float analog[8], int digital[8])
+ {
+ int t=0;
+ char buffer[7];
+
+ for (t=0;t<2;t++)
+ {
+ enum ELPError err=phidgetRead(phidgetDevice,buffer,sizeof(buffer));
+ if (err!=LPE_NONE)
+ return(_error(err));
+ if ((buffer[0] & 1)!=1)
+ {
+ // Packet 0
+ digital[0]=(buffer[0] & 16)==16;
+ digital[1]=(buffer[0] & 32)==32;
+ digital[2]=(buffer[0] & 64)==64;
+ digital[3]=(buffer[0] & 128)==128;
+
+ analog[7]=((unsigned char)buffer[1]+((unsigned char)buffer[2] & 0x0f) * 256);
+ analog[6]=((unsigned char)buffer[3]+((unsigned char)buffer[2] & 0xf0) * 16);
+ analog[5]=((unsigned char)buffer[4]+((unsigned char)buffer[5] & 0x0f) * 256);
+ analog[4]=((unsigned char)buffer[6]+((unsigned char)buffer[5] & 0xf0) * 16);
+ }
+ else
+ {
+ // Packet 1
+ digital[4]=(buffer[0] & 16)==16;
+ digital[5]=(buffer[0] & 32)==32;
+ digital[6]=(buffer[0] & 64)==64;
+ digital[7]=(buffer[0] & 128)==128;
+
+ analog[3]=((unsigned char)buffer[1]+((unsigned char)buffer[2] & 0x0f) * 256);
+ analog[2]=((unsigned char)buffer[3]+((unsigned char)buffer[2] & 0xf0) * 16);
+ analog[1]=((unsigned char)buffer[4]+((unsigned char)buffer[5] & 0x0f) * 256);
+ analog[0]=((unsigned char)buffer[6]+((unsigned char)buffer[5] & 0xf0) * 16);
+ }
+ }
+
+ return (_error(LPE_NONE));
}
Index: phidget.h
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** phidget.h 13 Dec 2002 16:42:30 -0000 1.8
--- phidget.h 13 Dec 2002 21:16:23 -0000 1.9
***************
*** 210,213 ****
--- 210,216 ----
enum ELPError phidget8Servo(struct phidget *phidgetDevice, int id, float percent1, float maxvelocity, float acceleration);
+ enum ELPError phidgetInterfaceKit448(struct phidget *phidgetDevice, float analog[4], int digital[8]);
+ enum ELPError phidgetInterfaceKit880(struct phidget *phidgetDevice, float analog[8], int digital[8]);
+
/**
* This checks for any new or changed devices, if anything has changed since the
|