示例#1
0
 def _after_write(self, buffer):
     """Pass the processed buffer down to the bottom layer."""
     if not self.connected_down:
         return
     # print('AutomaticPipe passing buffer down: {}'.format(buffer))
     self.write_down(buffer)
     yield from wait()  # wait for more buffer activity
示例#2
0
 def _after_read(self, buffer):
     """Pass the processed buffer up to the top layer."""
     if not self.connected_up:
         return
     # print('AutomaticPipe passing buffer up: {}'.format(buffer))
     self.read_up(buffer)
     yield from wait()  # wait for more buffer activity
示例#3
0
def incrementer_wait(last_received=[None]):
    """Increment every received number."""
    while True:
        number = yield from receive()
        yield from send(number + 1)
        yield from wait(
        )  # wait until data is added to the receive queue before proceeding
        last_received[0] = number
示例#4
0
    def _write_two(self, buffer):
        """Write the buffer to the connection.

        This is used to overwrite the after_write of the bottom of the pipeline
        if it's an automatic pipeline.
        """
        # print('Sending to pipeline one: {}'.format(buffer))
        self.pipeline_one.to_read(buffer)
        yield from wait()
示例#5
0
    def _write(self, buffer):
        """Write the buffer to the connection.

        This is used to overwrite the after_write of the bottom of the pipeline
        if it's an automatic pipeline.
        """
        try:
            if buffer:
                # print(buffer)
                self.connection.write(buffer)
        except serial.serialutil.SerialException:
            self.receiver_running = False
            self.has_receive.cancel()
            self.logger.error('Serial device disconnected!')
        yield from wait()
示例#6
0
 def after_write(self, buffer):
     """Do nothing."""
     yield from wait()
示例#7
0
 def after_send(self, event):
     """Do nothing."""
     yield from wait()
示例#8
0
 def after_read(self, buffer):
     """Do nothing."""
     yield from wait()
示例#9
0
 def after_receive(self, event):
     """Do nothing."""
     yield from wait()