From a427ccd1306edc00b3a51cda47ce9089a7f5f539 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 25 Sep 2017 20:42:53 +0200 Subject: [PATCH] fix devcie detection --- src/fenrir/core/eventManager.py | 2 +- src/fenrir/inputDriver/evdevDriver.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fenrir/core/eventManager.py b/src/fenrir/core/eventManager.py index fab6395e..d34ac94e 100644 --- a/src/fenrir/core/eventManager.py +++ b/src/fenrir/core/eventManager.py @@ -44,7 +44,7 @@ class eventManager(): elif event['Type'] == fenrirEventType.BrailleInput: pass elif event['Type'] == fenrirEventType.PlugInputDevice: - #self.env['runtime']['fenrirManager'].handlePlugInputDevice(event) + self.env['runtime']['fenrirManager'].handlePlugInputDevice(event) pass elif event['Type'] == fenrirEventType.BrailleFlush: pass diff --git a/src/fenrir/inputDriver/evdevDriver.py b/src/fenrir/inputDriver/evdevDriver.py index d36fcadc..1299222c 100644 --- a/src/fenrir/inputDriver/evdevDriver.py +++ b/src/fenrir/inputDriver/evdevDriver.py @@ -64,6 +64,8 @@ class driver(): while active.value == 1: devices = monitor.poll(2) if devices: + while monitor.poll(0.05): + time.sleep(0.01) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) return time.time() def plugInputDeviceWatchdogTimer(self, active): @@ -82,8 +84,7 @@ class driver(): while r == []: if active.value == 0: return - deviceFd = list(params['dev']) - r, w, x = select(deviceFd, [], [], 2) + r, w, x = select(list(params['dev']), [], [], 0.3) self.watchDog.value = 0 except: pass @@ -144,8 +145,7 @@ class driver(): if not self._initialized: return uDevice.write_event(event) - uDevice.syn() - time.sleep(0.00001) + uDevice.syn() def updateInputDevices(self, force = False, init = False): if init: @@ -201,7 +201,8 @@ class driver(): except Exception as e: self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR) self.iDeviceNo = len(evdev.list_devices()) - self.updateMPiDevicesFD() + self.updateMPiDevicesFD() + print(list(self.iDevicesFD)) def updateMPiDevicesFD(self): for fd in self.iDevices: if not fd in self.iDevicesFD: