fix VCSA watchdog if VCSA device does not exist

This commit is contained in:
chrys 2017-07-08 02:44:07 +02:00
parent a2acd14d9d
commit aacf1f02d1

View File

@ -7,6 +7,7 @@
import difflib import difflib
import re import re
import subprocess import subprocess
import glob, os
import fcntl import fcntl
import termios import termios
import time import time
@ -100,8 +101,10 @@ class driver():
def updateWatchdog(self,active , eventQueue): def updateWatchdog(self,active , eventQueue):
try: try:
vcsa = {} vcsa = {}
for i in range(1,7): vcsaDevices = glob.glob('/dev/vcsa*')
vcsa[str(i)] = open('/dev/vcsa'+str(i),'rb') for vcsaDev in vcsaDevices:
index = vcsaDev[9:]
vcsa[str(index)] = open(vcsaDev,'rb')
tty = open('/sys/devices/virtual/tty/tty0/active','r') tty = open('/sys/devices/virtual/tty/tty0/active','r')
currScreen = str(tty.read()[3:-1]) currScreen = str(tty.read()[3:-1])
@ -120,12 +123,21 @@ class driver():
tty.seek(0) tty.seek(0)
currScreen = str(tty.read()[3:-1]) currScreen = str(tty.read()[3:-1])
if currScreen != oldScreen: if currScreen != oldScreen:
watchdog.unregister(vcsa[ oldScreen ]) try:
watchdog.register(vcsa[ currScreen ], select.EPOLLPRI) watchdog.unregister(vcsa[ oldScreen ])
except:
pass
try:
watchdog.register(vcsa[ currScreen ], select.EPOLLPRI)
except:
pass
oldScreen = currScreen oldScreen = currScreen
eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''}) eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''})
vcsa[currScreen].seek(0) try:
lastScreenContent = vcsa[currScreen].read() vcsa[currScreen].seek(0)
lastScreenContent = vcsa[currScreen].read()
except:
lastScreenContent = b''
else: else:
self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO)
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
@ -135,6 +147,7 @@ class driver():
lastScreenContent = screenContent lastScreenContent = screenContent
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR)
def update(self, trigger='onUpdate'): def update(self, trigger='onUpdate'):
if trigger == 'onInput': # no need for an update on input for VCSA if trigger == 'onInput': # no need for an update on input for VCSA
return return