示例#1
0
 def run(self):
     self._flag_detector = utils.PatternDetector(self.FLAG)
     self._stuffing_bit_detector = utils.PatternDetector(self.STUFFING)
     self._successive_bits_detector = utils.PatternDetector(self.SUCCESSIVE)
     while True:
         # output phase and input phase correspond to
         # the two network.step(workers)
         # so wait(0) means go to next input phase (from output phase)
         # or go to next output phase (from input phase)
         # use context manager like this will increase the readability
         # it's actually just wait(0) in __exit__ of the context manager
         with mint.output_phase:
             if not self._oframe:
                 self.pull_frame()
             try:
                 obit = self._oframe.popleft()
             except IndexError:
                 obit = 0
             self.port.send(obit)
         with mint.input_phase:
             ibit = self.port.recv()
             self.process_input(ibit)
示例#2
0
 def setup(self):
     self._flag_detector = utils.PatternDetector(self.FLAG)
     self._stuffing_bit_detector = utils.PatternDetector(self.STUFFING)
     self._successive_bits_detector = utils.PatternDetector(self.SUCCESSIVE)