예제 #1
0
파일: devices.py 프로젝트: ver007/mint-dev
 def recv(self):
     data = ''
     flag = utils.bitify(self.flag)
     escape_byte = utils.bitify(self.escape_byte)
     # detect start flag
     while True:
         yield self.port.bit_arrive.event
         data += self.port.get(1)
         if data.endswith(flag):
             data = ''
             break
     # receive data until end flag
     while True:
         # receive 8 bits
         for _ in range(8):
             yield self.port.bit_arrive.event
             data += self.port.get(1)
         # check if is escaping
         if data.endswith(escape_byte):
             # delete the escaper byte
             data = data[:-8]
             # get the escapee byte
             for _ in range(8):
                 yield self.port.bit_arrive.event
                 data += self.port.get(1)
             continue
         # end flag detected
         if data.endswith(flag):
             data = data[:-8]
             break
     mint.ret(utils.unbitify(data))
예제 #2
0
파일: devices.py 프로젝트: fans656/mint-dev
 def recv(self):
     data = ''
     flag = utils.bitify(self.flag)
     escape_byte = utils.bitify(self.escape_byte)
     # detect start flag
     while True:
         yield self.port.bit_arrive.event
         data += self.port.get(1)
         if data.endswith(flag):
             data = ''
             break
     # receive data until end flag
     while True:
         # receive 8 bits
         for _ in range(8):
             yield self.port.bit_arrive.event
             data += self.port.get(1)
         # check if is escaping
         if data.endswith(escape_byte):
             # delete the escaper byte
             data = data[:-8]
             # get the escapee byte
             for _ in range(8):
                 yield self.port.bit_arrive.event
                 data += self.port.get(1)
             continue
         # end flag detected
         if data.endswith(flag):
             data = data[:-8]
             break
     mint.ret(utils.unbitify(data))
예제 #3
0
파일: devices.py 프로젝트: fans656/mint-dev
 def recv(self, nbytes):
     while len(self.data) < nbytes:
         yield self.port.bit_arrive.event
     ret, self.data = utils.split_at(self.data, nbytes)
     mint.ret(ret)
예제 #4
0
 def recv(self, nbytes):
     while len(self.data) < nbytes:
         yield self.port.bit_arrive.event
     ret, self.data = utils.split_at(self.data, nbytes)
     mint.ret(ret)