Update evdevDriver.py
This commit is contained in:
parent
2bd742e9ff
commit
f11c9eed3c
@ -36,7 +36,7 @@ class driver():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._manager = multiprocessing.Manager()
|
self._manager = multiprocessing.Manager()
|
||||||
self.iDevices = {}
|
self.iDevices = {}
|
||||||
self.iDevicesFD = None
|
self.iDevicesFD = self._manager.list()
|
||||||
self.uDevices = {}
|
self.uDevices = {}
|
||||||
self.iDeviceNo = 0
|
self.iDeviceNo = 0
|
||||||
self._initialized = False
|
self._initialized = False
|
||||||
@ -78,9 +78,9 @@ class driver():
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
def inputWatchdog(self,active , iDevicesFD):
|
def inputWatchdog(self,active , params):
|
||||||
deviceFd = []
|
deviceFd = []
|
||||||
for fd in iDevicesFD['dev']:
|
for fd in params['dev']:
|
||||||
deviceFd.append(fd)
|
deviceFd.append(fd)
|
||||||
while self.watchDog.value == 0:
|
while self.watchDog.value == 0:
|
||||||
if active.value == 0:
|
if active.value == 0:
|
||||||
@ -200,13 +200,15 @@ class driver():
|
|||||||
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR)
|
||||||
self.iDevicesFD = multiprocessing.Array('i', len(self.iDevices))
|
self.updateMPiDevicesFD()
|
||||||
i = 0
|
|
||||||
for fd in self.iDevices:
|
|
||||||
self.iDevicesFD[i] = fd
|
|
||||||
i +=1
|
|
||||||
self.iDeviceNo = len(evdev.list_devices())
|
self.iDeviceNo = len(evdev.list_devices())
|
||||||
|
def updateMPiDevicesFD(self):
|
||||||
|
for fd in self.iDevices:
|
||||||
|
if not fd in self.iDevicesFD:
|
||||||
|
self.iDevicesFD.append(fd)
|
||||||
|
for fd in self.iDevicesFD:
|
||||||
|
if not fd in self.iDevices:
|
||||||
|
self.iDevicesFD.remove(fd)
|
||||||
def mapEvent(self, event):
|
def mapEvent(self, event):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return None
|
||||||
@ -296,11 +298,8 @@ class driver():
|
|||||||
del(self.uDevices[fd])
|
del(self.uDevices[fd])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.iDevicesFD = multiprocessing.Array('i', len(self.iDevices))
|
self.updateMPiDevicesFD()
|
||||||
i = 0
|
|
||||||
for fd in self.iDevices:
|
|
||||||
self.iDevicesFD[i] = fd
|
|
||||||
i +=1
|
|
||||||
def hasIDevices(self):
|
def hasIDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user