From 13c61cb1a64c57b49f68d4ff0cd3cdb8cd8ca5f2 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 11 Apr 2018 23:57:28 +0200 Subject: [PATCH 01/10] systemd --- autostart/systemd/fenrir.service | 5 ++++- src/fenrir-daemon | 4 ++-- src/fenrirscreenreader/core/settingsManager.py | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/autostart/systemd/fenrir.service b/autostart/systemd/fenrir.service index 439a770d..eeeebd07 100644 --- a/autostart/systemd/fenrir.service +++ b/autostart/systemd/fenrir.service @@ -12,4 +12,7 @@ Restart=always #User=fenrirscreenreader [Install] -WantedBy=sound.target +# start as early as possible in boot process +#WantedBy=sound.target +# start as soon the login prompt is available +WantedBy=getty.target diff --git a/src/fenrir-daemon b/src/fenrir-daemon index 80a618a5..e813875c 100755 --- a/src/fenrir-daemon +++ b/src/fenrir-daemon @@ -22,7 +22,7 @@ def main(): if __name__ == "__main__": # for debug in foreground - #daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, foreground=True,chdir=os.path.dirname(os.path.realpath(fenrirVersion.__file__))) - daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, chdir=fenrirPath) + daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, foreground=True,chdir=fenrirPath) + #daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, chdir=fenrirPath) daemon.start() diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index abc2f4ef..16691f9a 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -279,6 +279,9 @@ class settingsManager(): environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'].initialize(environment) + environment['runtime']['helpManager'] = helpManager.helpManager() + environment['runtime']['helpManager'].initialize(environment) + environment['runtime']['byteManager'] = byteManager.byteManager() environment['runtime']['byteManager'].initialize(environment) @@ -310,8 +313,6 @@ class settingsManager(): environment['runtime']['cursorManager'].initialize(environment) environment['runtime']['applicationManager'] = applicationManager.applicationManager() environment['runtime']['applicationManager'].initialize(environment) - environment['runtime']['helpManager'] = helpManager.helpManager() - environment['runtime']['helpManager'].initialize(environment) environment['runtime']['headLineManager'] = headLineManager.headLineManager() environment['runtime']['headLineManager'].initialize(environment) environment['runtime']['tableManager'] = tableManager.tableManager() From d4a4605d6b3e2df9b11d9551d799326d9d765c28 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 16 May 2018 23:40:36 +0200 Subject: [PATCH 02/10] do not always grab on startup --- .../inputDriver/evdevDriver.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 6b784394..cec30c89 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -194,12 +194,15 @@ class driver(inputDriver): self.updateMPiDevicesFD() 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) + try: + 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) + except: + pass def mapEvent(self, event): if not self._initialized: return None @@ -275,9 +278,10 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) return def addDevice(self, newDevice): - self.iDevices[newDevice.fd] = newDevice + self.iDevices[newDevice.fd] = newDevice + self.gDevices[newDevice.fd] = False self.createUInputDev(newDevice.fd) - self.grabDevice(newDevice.fd) + #self.grabDevice(newDevice.fd) def grabDevice(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): return @@ -340,6 +344,5 @@ class driver(inputDriver): self.removeDevice(fd) self.iDevices.clear() self.uDevices.clear() + self.gDevices.clear() self.iDeviceNo = 0 - - From 09e3969531a966147b6d4d36eab75f33b4060bb3 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 00:13:21 +0200 Subject: [PATCH 03/10] fire event for plug only once --- .../inputDriver/evdevDriver.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index cec30c89..7e507f8a 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -54,8 +54,8 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) return self.updateInputDevices() - #if _udevAvailable: - # self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) + if _udevAvailable: + self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) #else: # self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer) self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog) @@ -65,11 +65,18 @@ class driver(inputDriver): monitor.filter_by(subsystem='input') monitor.start() while active.value: - devices = monitor.poll(2) - if devices: - while monitor.poll(1): + validDevice = False + device = monitor.poll(1) + while device: + try: + if not '/sys/devices/virtual/input/' in device.sys_path: + validDevice = True + device = monitor.poll(0.7) + except: pass + if validDevice: eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) + print('fired',device) return time.time() def plugInputDeviceWatchdogTimer(self, active): time.sleep(10) @@ -192,6 +199,7 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO) self.iDeviceNo = len(evdev.list_devices()) self.updateMPiDevicesFD() + print(self.gDevices) def updateMPiDevicesFD(self): try: From 6c7278350fba61f7873177791295317e0d6453ab Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 00:16:47 +0200 Subject: [PATCH 04/10] filter out uinput devices --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 7e507f8a..e06ed08f 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -172,6 +172,8 @@ class driver(inputDriver): currDevice = evdev.InputDevice(deviceFile) if currDevice.name.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']: continue + if currDevice.phys.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']: + continue if 'BRLTTY' in currDevice.name.upper(): continue cap = currDevice.capabilities() @@ -286,6 +288,7 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) return def addDevice(self, newDevice): + print(newDevice.fd,newDevice) self.iDevices[newDevice.fd] = newDevice self.gDevices[newDevice.fd] = False self.createUInputDev(newDevice.fd) From 6bd8e96b5a3ec24f3eb50c4fbfbd6fe7262b3a20 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 00:24:57 +0200 Subject: [PATCH 05/10] fire event for plug only once --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index e06ed08f..029b6e48 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -71,12 +71,11 @@ class driver(inputDriver): try: if not '/sys/devices/virtual/input/' in device.sys_path: validDevice = True - device = monitor.poll(0.7) + device = monitor.poll(0.5) except: pass if validDevice: eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) - print('fired',device) return time.time() def plugInputDeviceWatchdogTimer(self, active): time.sleep(10) @@ -255,12 +254,14 @@ class driver(inputDriver): if not self._initialized: return for fd in self.iDevices: - self.grabDevice(fd) + self.grabDevice(fd) + def ungrabAllDevices(self): if not self._initialized: return for fd in self.iDevices: self.ungrabDevice(fd) + def createUInputDev(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): self.uDevices[fd] = None From 4aea61d0201fcb2380f25478e4fad8b81422052d Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 00:34:51 +0200 Subject: [PATCH 06/10] cleanup --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 029b6e48..bcd94f94 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -200,7 +200,6 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO) self.iDeviceNo = len(evdev.list_devices()) self.updateMPiDevicesFD() - print(self.gDevices) def updateMPiDevicesFD(self): try: @@ -289,11 +288,9 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) return def addDevice(self, newDevice): - print(newDevice.fd,newDevice) self.iDevices[newDevice.fd] = newDevice self.gDevices[newDevice.fd] = False self.createUInputDev(newDevice.fd) - #self.grabDevice(newDevice.fd) def grabDevice(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): return From b2c9837ef19954c3fa939d29b55a4a1cac700e85 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 00:52:35 +0200 Subject: [PATCH 07/10] add debug --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index bcd94f94..1d457aa4 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -288,6 +288,7 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) return def addDevice(self, newDevice): + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device added: ' + str(newDevice.fd) + ' ' +str(newDevice),debug.debugLevel.INFO) self.iDevices[newDevice.fd] = newDevice self.gDevices[newDevice.fd] = False self.createUInputDev(newDevice.fd) @@ -308,7 +309,7 @@ class driver(inputDriver): except: pass def removeDevice(self,fd): - self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.INFO) self.clearEventBuffer() try: self.ungrabDevice(fd) From ecee654546aa51db15905eac3e637d9ccd3f27e9 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 17 May 2018 01:01:17 +0200 Subject: [PATCH 08/10] increase wait time --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 1d457aa4..c4e8b454 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -84,7 +84,7 @@ class driver(inputDriver): def inputWatchdog(self,active , eventQueue): try: while active.value: - r, w, x = select(self.iDevices, [], [], 0.5) + r, w, x = select(self.iDevices, [], [], 0.7) for fd in r: event = None foreward = False From 79d877f7603e229307c3250b2a26e30472dcf59c Mon Sep 17 00:00:00 2001 From: chrys87 Date: Thu, 17 May 2018 09:30:43 +0200 Subject: [PATCH 09/10] Update fenrirManager.py --- src/fenrirscreenreader/core/fenrirManager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 9f2a885a..399f4d56 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -166,6 +166,7 @@ class fenrirManager(): #print('handleScreenUpdate:',time.time() - startTime) def handlePlugInputDevice(self, event): + self.environment['runtime']['inputManager'].updateInputDevices() self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True) def handleHeartBeat(self, event): From c0691c7daf0f784976c1125397c2b655417b3ed8 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Thu, 17 May 2018 09:31:15 +0200 Subject: [PATCH 10/10] Update 50000-UpdateDevices.py --- .../commands/onPlugInputDevice/50000-UpdateDevices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py index fa2d364a..8e925bfe 100755 --- a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py +++ b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py @@ -16,6 +16,6 @@ class command(): def getDescription(self): return 'No description found' def run(self): - self.env['runtime']['inputManager'].updateInputDevices() + pass def setCallback(self, callback): pass