diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 19:30:43 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 19:30:43 +0000 |
commit | 477e8e9570cebe9152c011a76defd6e9ce21fac7 (patch) | |
tree | 257399dd5eb402a14de37452069e080662c5c1c3 /cphidgetmanager.c | |
parent | 827093b9a63335655c696d4beb3134613c4414e6 (diff) | |
parent | 46bd2ba42d186a81d7ad7e4a55e03dd63b2d042f (diff) | |
download | libphidget21-477e8e9570cebe9152c011a76defd6e9ce21fac7.tar.gz |
Merge tag 'upstream/2.1.8.20121218'
Upstream version 2.1.8.20121218
Diffstat (limited to 'cphidgetmanager.c')
-rw-r--r-- | cphidgetmanager.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/cphidgetmanager.c b/cphidgetmanager.c index d0f918b..7471deb 100644 --- a/cphidgetmanager.c +++ b/cphidgetmanager.c @@ -177,7 +177,7 @@ static int sendInitialEvents() int CPhidgetManager_poll() { CPhidgetList *curList = 0, *detachList = 0; - CPhidgetList *trav = 0; + CPhidgetList *trav = 0, *trav2 = 0; CPhidgetHandle foundPhidget; if(!managerLockInitialized) @@ -203,8 +203,7 @@ int CPhidgetManager_poll() } for (trav=curList; trav; trav = trav->next) { - if(CList_findInList((CListHandle)AttachedDevices, trav->phid, CPhidget_areExtraEqual, NULL) == - EPHIDGET_NOTFOUND) + if(CList_findInList((CListHandle)AttachedDevices, trav->phid, CPhidget_areExtraEqual, NULL) == EPHIDGET_NOTFOUND) { CPhidgetAttachEvent(trav->phid); } @@ -215,15 +214,27 @@ int CPhidgetManager_poll() CThread_mutex_lock(&activeDevicesLock); if(CList_findInList((CListHandle)ActiveDevices, trav->phid, CPhidget_areEqual, (void **)&foundPhidget) == EPHIDGET_OK) { - if(CPhidget_statusFlagIsSet(foundPhidget->status, PHIDGET_ATTACHED_FLAG)) + if(CPhidget_statusFlagIsSet(foundPhidget->status, PHIDGET_ATTACHED_FLAG) + && CPhidget_statusFlagIsSet(foundPhidget->status, PHIDGET_USB_ERROR_FLAG)) { - if(CPhidget_statusFlagIsSet(foundPhidget->status, PHIDGET_USB_ERROR_FLAG)) + LOG(PHIDGET_LOG_WARNING,"PHIDGET_USB_ERROR_FLAG is set - cycling device through a detach"); + CList_addToList((CListHandle *)&detachList, trav->phid, CPhidget_areEqual); + + //if this is a composite device, we must find it's pair and detach that as well. + //same serial, but different interface num + for (trav2=curList; trav2; trav2 = trav2->next) { - LOG(PHIDGET_LOG_WARNING,"PHIDGET_USB_ERROR_FLAG is set - cycling device through a detach"); - CList_addToList((CListHandle *)&detachList, trav->phid, CPhidget_areEqual); + if(trav->phid->serialNumber == trav2->phid->serialNumber + && trav->phid->deviceDef->pdd_iid != trav2->phid->deviceDef->pdd_iid) + { + LOG(PHIDGET_LOG_WARNING,"PHIDGET_USB_ERROR_FLAG is set - cycling composite device 2nd interface through a detach"); + CList_addToList((CListHandle *)&detachList, trav2->phid, CPhidget_areEqual); + } } } } + + CThread_mutex_unlock(&activeDevicesLock); } for (trav=detachList; trav; trav = trav->next) |