diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 20:04:36 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 20:04:36 +0000 |
commit | 571d570e1be6f783a2e8ef0dafa838e9d82f923e (patch) | |
tree | 9b18682751acba56d650129922ecc4c5f12a3469 /cphidgetmanager.c | |
parent | 62172377c57ff85bce35a43e0ca3e76f67a473ad (diff) | |
parent | 4e6290d8e2dc4dcd784102bdab18d7e1854e11c0 (diff) | |
download | libphidget21-571d570e1be6f783a2e8ef0dafa838e9d82f923e.tar.gz |
Merge branch 'master' into squeeze-backportssqueeze-backports
Conflicts:
debian/changelog
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) |