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
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
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
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()
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()
def after_write(self, buffer): """Do nothing.""" yield from wait()
def after_send(self, event): """Do nothing.""" yield from wait()
def after_read(self, buffer): """Do nothing.""" yield from wait()
def after_receive(self, event): """Do nothing.""" yield from wait()