'Loop and copy console->serial until self.exit_character character is
found. When self.menu_character is found, interpret the next key
locally.'

def writer(self):

    menu_active = False
    try:
        while self.alive:
            try:
                c = self.console.getkey()
            except KeyboardInterrupt:
                c = '\x03'
            if (not self.alive):
                break
            if menu_active:
                self.handle_menu_key(c)
                menu_active = False
            elif (c == self.menu_character):
                menu_active = True
            elif (c == self.exit_character):
                self.stop()
                break
            else:
                text = c
                for transformation in self.tx_transformations:
                    text = transformation.tx(text)
                self.serial.write(self.tx_encoder.encode(text))
                if self.echo:
                    echo_text = c
                    for transformation in self.tx_transformations:
                        echo_text = transformation.echo(echo_text)
                    self.console.write(echo_text)
    except:
        self.alive = False
        raise
