[Libphidget-cvs-commits] CVS: libphidget/src/libphidget phidget.c,1.28,1.29
Status: Alpha
Brought to you by:
jstrohm
From: Jack S. <js...@us...> - 2003-06-23 22:47:05
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory sc8-pr-cvs1:/tmp/cvs-serv25891/src/libphidget Modified Files: phidget.c Log Message: Fixed problem with softphidget/regular phidgets not working together, now they should all play nicely Index: phidget.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** phidget.c 23 Jun 2003 22:37:34 -0000 1.28 --- phidget.c 23 Jun 2003 22:47:02 -0000 1.29 *************** *** 144,148 **** * Test if the phidget type is a soft phidget */ ! int _isSoftPhidget(struct phidget_type *pdt) { switch(pdt->productID) --- 144,148 ---- * Test if the phidget type is a soft phidget */ ! int _isSoftPhidget(const struct phidget_type *pdt) { switch(pdt->productID) *************** *** 1205,1208 **** --- 1205,1209 ---- int a,b; int ret; + DBG("phidgetWrite"); if (_libPhidgetInitialized == 0) *************** *** 1215,1222 **** return (_error(LPE_PHIDGET_NOT_OPENED)); ! ! // If this isn't a soft phidget we use control messages so ! /* ! ret=usb_control_msg(phidgetDevice->handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); if (ret!=size) --- 1216,1229 ---- return (_error(LPE_PHIDGET_NOT_OPENED)); ! if (_isSoftPhidget(phidgetType(phidgetDevice))==0) ! { ! // If this isn't a soft phidget we use control messages so ! ret=usb_control_msg(phidgetDevice->handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); ! } ! else ! { ! // Only works for writing to soft phidgets ! ret=usb_bulk_write(phidgetDevice->handle, 0x01, (void *)buffer,size, 5000); ! } if (ret!=size) *************** *** 1227,1280 **** return (_error(LPE_CONTROL_MSG_ERROR)); } - */ - - - // Only works for writing to soft phidgets - ret=usb_bulk_write(phidgetDevice->handle, 0x01, (void *)buffer,size, 5000); - printf("%d\n",ret); - - - // Keep trying - //ret=usb_control_msg(phidgetDevice->handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); - - //for (a=0;a<255;a++) - //for (b=0;b<255;b++) - //{ - //ret=usb_control_msg(phidgetDevice->handle, a, b, 0x200, 0, buffer, size, 5000); - //if (ret!=-1) - //printf("%d %d %d\n",a,b,ret); - //} - //exit(-1); - - - //128 6 16 - //ret=usb_control_msg(phidgetDevice->handle, 0x21, 0x09, 0x200, 0, buffer, size, 5000); - //ret=usb_control_msg(phidgetDevice->handle, 128, 6, 0x200, 0, buffer, size, 5000); - - - /* - sizeleft=size; - wrote=0; - - while (sizeleft>0) - { - printf("Try to write %d\n",sizeleft); - ret=usb_bulk_write(phidgetDevice->handle, 0x01, (void *)(buffer+wrote),sizeleft, 5000); - - if (ret!=-1) - { - if (ret<0) - { - char temp[64]; - sprintf(temp,"Tried to write %d, but got error %d\n",size,ret); - DBG(temp); - return (_error(LPE_CONTROL_MSG_ERROR)); - } - - sizeleft-=ret; - wrote+=ret; - } - } - */ --- 1234,1237 ---- |