示例#1
0
	def connectUSB(self,devlist):
		"""try to connect to usb device,is triggered when BRXCOM is not installed and bluetooth
connection could not be established"""
		try:
			self._dev = ftdi2.open_ex(devlist[0])
			self._dev.set_baud_rate(self._baud)
			self._dev.inWaiting = self._dev.get_queue_status
			log.info("connectUSB success")
		except:
			log.debugWarning("connectUSB failed")
示例#2
0
    def connectUSB(self, devlist: List[bytes]):
        """Try to connect to usb device, this is triggered when bluetooth
connection could not be established"""
        try:
            self._dev = ftdi2.open_ex(devlist[0])
            self._dev.set_baud_rate(self._baud)
            self._dev.inWaiting = self._dev.get_queue_status
            log.info("connectUSB success")
        except:
            log.debugWarning("connectUSB failed")
示例#3
0
    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)
示例#4
0
    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)