add debug

This commit is contained in:
chrys 2018-04-15 15:43:03 +02:00
parent b5f7526345
commit dab2d4ca75

View File

@ -75,38 +75,41 @@ class driver(inputDriver):
return time.time() return time.time()
def inputWatchdog(self,active , eventQueue): def inputWatchdog(self,active , eventQueue):
while active.value: try:
r, w, x = select(self.iDevices, [], [], 0.5) while active.value:
for fd in r: r, w, x = select(self.iDevices, [], [], 0.5)
event = None for fd in r:
foreward = False event = None
eventFired = False foreward = False
try: eventFired = False
event = self.iDevices[fd].read_one() try:
except: event = self.iDevices[fd].read_one()
self.removeDevice(fd) except:
while(event): self.removeDevice(fd)
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) while(event):
if event.type == evdev.events.EV_KEY: self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
if event.code != 0: if event.type == evdev.events.EV_KEY:
currMapEvent = self.mapEvent(event) if event.code != 0:
if not currMapEvent: currMapEvent = self.mapEvent(event)
foreward = True if not currMapEvent:
if not isinstance(currMapEvent['EventName'], str): foreward = True
foreward = True if not isinstance(currMapEvent['EventName'], str):
if not foreward or eventFired: foreward = True
if currMapEvent['EventState'] in [0,1,2]: if not foreward or eventFired:
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) if currMapEvent['EventState'] in [0,1,2]:
eventFired = True eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
else: eventFired = True
if not event.type in [0,4]: else:
foreward = True if not event.type in [0,4]:
foreward = True
event = self.iDevices[fd].read_one()
if foreward and not eventFired: event = self.iDevices[fd].read_one()
self.writeEventBuffer() if foreward and not eventFired:
self.clearEventBuffer() self.writeEventBuffer()
self.clearEventBuffer()
except Exception as e:
self.env['runtime']['debug'].writeDebugOut("INPUT WATCHDOG CRASH: "+str(e),debug.debugLevel.ERROR)
def handleInputEvent(self, event): def handleInputEvent(self, event):
return return
@ -184,7 +187,6 @@ class driver(inputDriver):
self.grabDevice(currDevice.fd) self.grabDevice(currDevice.fd)
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:
print(e)
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
self.iDeviceNo = len(evdev.list_devices()) self.iDeviceNo = len(evdev.list_devices())
self.updateMPiDevicesFD() self.updateMPiDevicesFD()