Beispiel #1
0
def main(serial_id):
    port = SerialPort(serial_id)
    monitor = DockerMonitor()

    signal.signal(signal.SIGINT, signal_handler)
    print('Welcome to TX')
    print_help()

    readline.parse_and_bind("tab:complete")
    readline.set_completer(completer)
    while True:
        user_input = input('#: ')
        tokens = user_input.split()
        global commands
        commands = commands + monitor.get_tags()

        if len(tokens) == 0:
            continue

        cmd = tokens[0]

        if cmd == 'help':
            print_help()
        elif cmd == 'tags':
            port.write(cmd)
        elif cmd == 'exit':
            break
        elif cmd == 'run':
            if len(tokens) < 2:
                tag = 'latest'
            else:
                tag = tokens[1]
            port.write(cmd + ' ' + tag)
        elif cmd == 'pull':
            if len(tokens) < 2:
                tag = 'latest'
            else:
                tag = tokens[1]
            port.write(cmd + ' ' + tag)
        elif cmd == 'clean':
            port.write(cmd)
        elif cmd == 'reboot':
            port.write(cmd)
        else:
            print('Unknown command: {}'.format(cmd))
            continue

        # Wait for and print all messages received from rx
        wait_for_end_of_message_or_print(port)

    # Close port on exit
    port.close()
    monitor.close()
Beispiel #2
0
class AirPuff():
    def __init__(self, portName):
        self.ser = None

        if portName is None or portName == "None":
            return

        self.ser = SerialPort(serialPortName=portName, baudRate=57600)
        self.ser.startReadThread()

    def puff(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("x")

    def open_valve(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("1")

    def close_valve(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("0")
Beispiel #3
0
class AirPuff():

    def __init__(self, portName):
        self.ser = None

        if portName is None or portName == "None":
            return

        self.ser = SerialPort(serialPortName=portName, baudRate=57600)
        self.ser.startReadThread()

    def puff(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("x")

    def open_valve(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("1")

    def close_valve(self):
        if self.ser is None:
            print "No air puff connected."
            return
        self.ser.write("0")
Beispiel #4
0
def main():
    port = SerialPort("/dev/acrobat/radio")
    monitor = DockerMonitor()

    print("Sending start up lights")
    port.send_start()
    time.sleep(1)
    print("Done. Ready for user input")

    while True:
        user_input = port.read()
        tokens = user_input.split()

        if len(tokens) == 0:
            continue

        cmd = tokens[0]

        if cmd == 'run':
            exec_run(port, monitor, tokens)
        elif cmd == 'pull':
            exec_pull(port, monitor, tokens)
        elif cmd == 'tags':
            exec_tags(port, monitor)
        elif cmd == 'clean':
            exec_clean(port, monitor)
        elif cmd == 'reboot':
            exec_reboot(port, monitor)
        else:
            port.write('Unknown command: {}'.format(cmd))

        # End of command execution
        port.send_end_of_command()

    port.close()
    monitor.close()