def _handleKeyPresses(self): """handles key presses and performs a gesture""" try: if (self._brxnvda): k = self._brxnvda.brxnvda_keyIndex() if (k != -1): self.executeGesture(InputGesture(k, self)) return if (self._dev is None and self._baud > 0): try: devlist = ftdi2.list_devices() if (len(devlist) > 0): self.connectUSB(devlist) except: return s = brl_poll(self._dev) if s: self._repeatcount = 0 ig = InputGesture(s, self) self.executeGesture(ig) else: if (len(self.decodedkeys)): ig = InputGesture(None, self) self.executeGesture(ig) except: if (self._dev != None): self._dev.close() self._dev = None
def _handleKeyPresses(self): """handles key presses and performs a gesture""" try: if(self._brxnvda): k = self._brxnvda.brxnvda_keyIndex() if(k!=-1): self.executeGesture(InputGesture(k,self)) return if(self._dev is None and self._baud>0): try: devlist = ftdi2.list_devices() if(len(devlist)>0): self.connectUSB(devlist) except: return s = brl_poll(self._dev) if s: self._repeatcount=0 ig = InputGesture(s,self) self.executeGesture(ig) else: if(len(self.decodedkeys)): ig = InputGesture(None,self) self.executeGesture(ig) except: if(self._dev!=None): self._dev.close() self._dev=None
def readFun(self): try: dev = ft.list_devices() except: dev = [] while len (dev) == 0: time.sleep (5) print "Rechecking hardware connection..." try: dev = ft.list_devices() except: dev = [] self.f = ft.open_ex(dev[0]) print self.f while True: item = self.q.get() self.f.write(item) print repr(item)
def readFun(self): try: dev = ft.list_devices() except: dev = [] while len (dev) == 0: time.sleep (5) print "Rechecking hardware connection..." try: dev = ft.list_devices() except: dev = [] self.f = ft.open_ex(dev[0]) print self.f while True: datalistR = [None]*14 item = self.q.get() self.f.write(item) time.sleep(0.1) readData = self.f.read (self.f.get_queue_status()) print repr(readData) fmtR = '@14B' (datalistR[0],datalistR[1],datalistR[2],datalistR[3],datalistR[4],datalistR[5], datalistR[6],datalistR[7],datalistR[8],datalistR[9],datalistR[10],datalistR[11], datalistR[12],datalistR[13]) = struct.unpack(fmtR,readData) listHead = [1] * 16 allHead = datalistR[10] * 256 + datalistR[11] a = 1 for i in range(16): if a & allHead: listHead[i] = 0 a = a * 2 self.p.put(listHead)
def __init__(self): """initialize driver""" super(BrailleDisplayDriver, self).__init__() self.numCells = 0 self._nlk = 0 self._nrk = 0 self.decodedkeys = [] self._baud = 0 self._dev = None self._proto = None devlist = [] self.connectBrxCom() if(self._baud == 1): return #brxcom is running, skip bluetooth and USB #try to connect to usb device, #if no usb device is found there may be a bluetooth device if ftdi2: devlist = ftdi2.list_devices() if(len(devlist)==0): self.connectBluetooth() elif ftdi2: self._baud = 57600 self.connectUSB(devlist) if(self._dev is None): return None try: #request type of braille display self._dev.write(brl_auto_id()) time.sleep(0.05)# wait 50 ms in order to get response for further actions autoid=brl_poll(self._dev) if(autoid == ''): #no response, assume a Trio is connected self._baud = 115200 self._dev.set_baud_rate(self._baud) self._dev.purge() self._dev.read(self._dev.inWaiting()) self.numCells = 40 self._proto = 'B' self._voffset = 0 #we don't use autoid here, because the trio might be switched off and other braille displays using the same baud rate do not exist else: if(len(autoid) != 8): return None autoid = struct.unpack('BBBBBBBB',autoid) if(autoid[3] == 0x35 and autoid[4] == 0x38):#EL80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80s") elif(autoid[3]==0x35 and autoid[4]==0x3A):#EL70s self.numCells = 70 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL70s") elif(autoid[3]==0x35 and autoid[4]==0x35):#EL40s self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40s") elif(autoid[3] == 0x35 and autoid[4] == 0x37):#EL66s self.numCells = 66 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL66s") elif(autoid[3] == 0x35 and autoid[4] == 0x3E):#EL20c self.numCells = 20 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL20c") elif(autoid[3] == 0x35 and autoid[4] == 0x3F):#EL40c self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40c") elif(autoid[3] == 0x36 and autoid[4] == 0x30):#EL60c self.numCells = 60 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL60c") elif(autoid[3] == 0x36 and autoid[4] == 0x31):#EL80c self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80c") elif(autoid[3] == 0x35 and autoid[4] == 0x3b):#EL2D80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 20 log.info("Found EL2D80s") else: log.debugWarning('UNKNOWN BRAILLE') except: log.debugWarning('BROKEN PIPE - THIS SHOULD NEVER HAPPEN') if(self.numCells == 0): raise Exception('no device found') #start keycheck timer self.startTimer() self.initmapping()
def __init__(self): """initialize driver""" super(BrailleDisplayDriver, self).__init__() self.numCells = 0 self._nlk = 0 self._nrk = 0 self.decodedkeys = [] self._baud = 0 self._dev = None self._proto = None devlist: List[bytes] = [] #try to connect to usb device, #if no usb device is found there may be a bluetooth device if ftdi2: devlist = ftdi2.list_devices() if (len(devlist) == 0): self.connectBluetooth() elif ftdi2: self._baud = 57600 self.connectUSB(devlist) if (self._dev is not None): try: #request type of braille display self._dev.write(brl_auto_id()) time.sleep( 0.05 ) # wait 50 ms in order to get response for further actions autoid: bytes = brl_poll(self._dev) if autoid == b'': #no response, assume a Trio is connected self._baud = 115200 self._dev.set_baud_rate(self._baud) self._dev.purge() self._dev.read(self._dev.inWaiting()) #request type of braille display twice because of baudrate change self._dev.write(brl_auto_id()) self._dev.write(brl_auto_id()) time.sleep( 0.05 ) # wait 50 ms in order to get response for further actions autoid = brl_poll(self._dev) if len(autoid) != 8: return else: if (autoid[3] == 0x35 and autoid[4] == 0x38): #EL80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80s") elif (autoid[3] == 0x35 and autoid[4] == 0x3A): #EL70s self.numCells = 70 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL70s") elif (autoid[3] == 0x35 and autoid[4] == 0x35): #EL40s self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40s") elif (autoid[3] == 0x35 and autoid[4] == 0x37): #EL66s self.numCells = 66 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL66s") elif (autoid[3] == 0x35 and autoid[4] == 0x3E): #EL20c self.numCells = 20 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL20c") elif (autoid[3] == 0x35 and autoid[4] == 0x3F): #EL40c self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40c") elif (autoid[3] == 0x36 and autoid[4] == 0x30): #EL60c self.numCells = 60 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL60c") elif (autoid[3] == 0x36 and autoid[4] == 0x31): #EL80c self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80c") elif (autoid[3] == 0x35 and autoid[4] == 0x3b): #EL2D80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 20 log.info("Found EL2D80s") elif (autoid[3] == 0x35 and autoid[4] == 0x39): #trio self.numCells = 40 self._proto = 'B' self._voffset = 0 log.info("Found trio") elif (autoid[3] == 0x36 and autoid[4] == 0x34): #live20 self.numCells = 20 self._proto = 'B' self._voffset = 0 log.info("Found live 20") elif (autoid[3] == 0x36 and autoid[4] == 0x33): #live+ self.numCells = 40 self._proto = 'B' self._voffset = 0 log.info("Found live+") elif (autoid[3] == 0x36 and autoid[4] == 0x32): #live self.numCells = 40 self._proto = 'B' self._voffset = 0 log.info("Found live") else: log.debugWarning('UNKNOWN BRAILLE') except: log.debugWarning('BROKEN PIPE - THIS SHOULD NEVER HAPPEN') if (self.numCells == 0): raise Exception('no device found') #start keycheck timer self.startTimer() self.initmapping()
def __init__(self): """initialize driver""" super(BrailleDisplayDriver, self).__init__() self.numCells = 0 self._nlk = 0 self._nrk = 0 self._r1next = itertools.cycle(('r1a', 'r1b')) self.decodedkeys = [] self._baud = 0 self._dev = None self._proto = None self.connectBrxCom() if (self._baud == 1): return #brxcom is running, skip bluetooth and USB #try to connect to usb device, #if no usb device is found there may be a bluetooth device try: devlist = ftdi2.list_devices() except: devlist = [] if (len(devlist) == 0): self.connectBluetooth() else: self._baud = 57600 self.connectUSB(devlist) if (self._dev is None): return None try: #request type of braille display self._dev.write(brl_auto_id()) time.sleep( 0.05 ) # wait 50 ms in order to get response for further actions autoid = brl_poll(self._dev) if (autoid == ''): #no response, assume a Trio is connected self._baud = 115200 self._dev.set_baud_rate(self._baud) self._dev.purge() self._dev.read(self._dev.inWaiting()) self.numCells = 40 self._proto = 'B' self._voffset = 0 #we don't use autoid here, because the trio might be switched off and other braille displays using the same baud rate do not exist else: if (len(autoid) != 8): return None autoid = struct.unpack('BBBBBBBB', autoid) if (autoid[3] == 0x35 and autoid[4] == 0x38): #EL80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80s") elif (autoid[3] == 0x35 and autoid[4] == 0x3A): #EL70s self.numCells = 70 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL70s") elif (autoid[3] == 0x35 and autoid[4] == 0x35): #EL40s self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40s") elif (autoid[3] == 0x35 and autoid[4] == 0x37): #EL66s self.numCells = 66 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL66s") elif (autoid[3] == 0x35 and autoid[4] == 0x3E): #EL20c self.numCells = 20 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL20c") elif (autoid[3] == 0x35 and autoid[4] == 0x3F): #EL40c self.numCells = 40 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL40c") elif (autoid[3] == 0x36 and autoid[4] == 0x30): #EL60c self.numCells = 60 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL60c") elif (autoid[3] == 0x36 and autoid[4] == 0x31): #EL80c self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 0 log.info("Found EL80c") elif (autoid[3] == 0x35 and autoid[4] == 0x3b): #EL2D80s self.numCells = 80 self._nlk = 1 self._nrk = 1 self._proto = 'A' self._voffset = 20 log.info("Found EL2D80s") else: log.debugWarning('UNKNOWN BRAILLE') except: log.debugWarning('BROKEN PIPE - THIS SHOULD NEVER HAPPEN') if (self.numCells == 0): raise Exception('no device found') #start keycheck timer self.startTimer() self.initmapping()