Update vcsaDriver.py

This commit is contained in:
chrys 2023-02-18 15:08:53 +01:00 committed by GitHub
parent cd421712f5
commit be6e1be785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,15 +95,25 @@ class driver(screenDriver):
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('getSessionInformation: Maybe no LoginD:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('getSessionInformation: Maybe no LoginD:' + str(e),debug.debugLevel.ERROR)
#self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO) #self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO)
def readFile(self, file):
def updateWatchdog(self,active , eventQueue): d = b''
file.seek(0)
try:
d = file.read()
except:
file.seek(0)
while True:
# Read from file
try:
d += file.readline(1)
if not d:
break
except Exception as e:
break
return d
def updateWatchdog(self, active , eventQueue):
try: try:
useVCSU = os.access('/dev/vcsu', os.R_OK) useVCSU = os.access('/dev/vcsu', os.R_OK)
try:
with open('/dev/vcsu', 'rb') as vcsuDummyFile:
d = vcsuDummyFile.read()
except:
useVCSU = False
vcsa = {} vcsa = {}
vcsaDevices = glob.glob('/dev/vcsa*') vcsaDevices = glob.glob('/dev/vcsa*')
vcsu = {} vcsu = {}
@ -116,7 +126,7 @@ class driver(screenDriver):
index = str(vcsaDev[9:]) index = str(vcsaDev[9:])
vcsa[index] = open(vcsaDev,'rb') vcsa[index] = open(vcsaDev,'rb')
if index == currScreen: if index == currScreen:
lastScreenContent = vcsa[index].read() lastScreenContent = self.readFile(vcsa[index])
if useVCSU: if useVCSU:
vcsuDevices = glob.glob('/dev/vcsu*') vcsuDevices = glob.glob('/dev/vcsu*')
for vcsuDev in vcsuDevices: for vcsuDev in vcsuDevices:
@ -148,13 +158,13 @@ class driver(screenDriver):
oldScreen = currScreen oldScreen = currScreen
try: try:
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
lastScreenContent = vcsa[currScreen].read() lastScreenContent = readFile(vcsa[currScreen])
except: except:
pass pass
vcsuContent = None vcsuContent = None
if useVCSU: if useVCSU:
vcsu[currScreen].seek(0) vcsu[currScreen].seek(0)
vcsuContent = vcsu[currScreen].read() vcsuContent = readFile(vcsu[currScreen])
eventQueue.put({"Type":fenrirEventType.ScreenChanged, eventQueue.put({"Type":fenrirEventType.ScreenChanged,
"Data":self.createScreenEventData(currScreen, lastScreenContent, vcsuContent) "Data":self.createScreenEventData(currScreen, lastScreenContent, vcsuContent)
}) })
@ -162,7 +172,7 @@ class driver(screenDriver):
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)
time.sleep(0.01) time.sleep(0.01)
dirtyContent = vcsa[currScreen].read() dirtyContent = readFile(vcsa[currScreen])
screenContent = dirtyContent screenContent = dirtyContent
vcsuContent = None vcsuContent = None
timeout = time.time() timeout = time.time()
@ -188,7 +198,7 @@ class driver(screenDriver):
#if not vcsa[currScreen] in r: #if not vcsa[currScreen] in r:
# break # break
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
dirtyContent = vcsa[currScreen].read() dirtyContent = readFile(vcsa[currScreen])
if screenContent == dirtyContent: if screenContent == dirtyContent:
break break
if time.time() - timeout >= 0.1: if time.time() - timeout >= 0.1:
@ -196,7 +206,7 @@ class driver(screenDriver):
break break
if useVCSU: if useVCSU:
vcsu[currScreen].seek(0) vcsu[currScreen].seek(0)
vcsuContent = vcsu[currScreen].read() vcsuContent = readFile(vcsu[currScreen])
lastScreenContent = screenContent lastScreenContent = screenContent
eventQueue.put({"Type":fenrirEventType.ScreenUpdate, eventQueue.put({"Type":fenrirEventType.ScreenUpdate,
"Data":self.createScreenEventData(currScreen, screenContent, vcsuContent) "Data":self.createScreenEventData(currScreen, screenContent, vcsuContent)