From adc538424900701f2439ebe4106cfa9f61811d12 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 8 Oct 2016 11:45:17 +0200 Subject: [PATCH] do cleanups --- src/fenrir/brailleDriver/brlapi.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/fenrir/brailleDriver/brlapi.py b/src/fenrir/brailleDriver/brlapi.py index 031e370d..0bbc7f2d 100644 --- a/src/fenrir/brailleDriver/brlapi.py +++ b/src/fenrir/brailleDriver/brlapi.py @@ -20,34 +20,42 @@ class driver(): return try: - self.connectDevice() + self.connectDevice() except Exception as e: - self.env['runtime']['debug'].writeDebugOut('BRAILLE.connectDevice '+str(e),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut('BRAILLE.connectDevice '+str(e),debug.debugLevel.ERROR) return self._isInitialized = True - + def flush(self): if not self._isInitialized: return try: self._brl.writeText('',0) except Exception as e: - self.env['runtime']['debug'].writeDebugOut('BRAILLE.flush '+str(e),debug.debugLevel.ERROR) - + self.env['runtime']['debug'].writeDebugOut('BRAILLE.flush '+str(e),debug.debugLevel.ERROR) + def writeText(self,text): if not self._isInitialized: return try: self._brl.writeText(text) except Exception as e: - self.env['runtime']['debug'].writeDebugOut('BRAILLE.writeText '+str(e),debug.debugLevel.ERROR) - + self.env['runtime']['debug'].writeDebugOut('BRAILLE.writeText '+str(e),debug.debugLevel.ERROR) + def connectDevice(self): self._brl = brlapi.Connection() - self._brl.enterTtyModeWithPath() - + + def enterTTY(self): + if not self._isInitialized: + return + self._brl.enterTtyModeWithPath() + + def leveTTY(self): + if not self._isInitialized: + return + self._brl.leaveTtyMode() + def shutdown(self): if not self._isInitialized: return - self._brl.leaveTtyMode() - + self.leveTTY()