diff --git a/tools/logClusterBootup.sh b/tools/logClusterBootup.sh index f6d49fd..b6a9e26 100755 --- a/tools/logClusterBootup.sh +++ b/tools/logClusterBootup.sh @@ -1,9 +1,12 @@ #!/bin/bash # reset the mux device to default values -pypy ./muxctrl.py -g -m -l 0 -s 115200 +python ./muxctrl.py -g -m -l 0 -s 115200 # TODO start logging of the received data +./readTTYToFile.sh /dev/ttyACM1 & + +sleep 2 # read from line 0 to 7 for i in `seq 0 7`; @@ -18,6 +21,7 @@ done sleep 3 # TODO stop logging of the received data +killall -12 readTTYToFile.sh -pypy ./muxctrl.py -g -m -l 0 -s 115200 +python ./muxctrl.py -g -m -l 0 -s 115200 diff --git a/tools/muxctrl.py b/tools/muxctrl.py index ec19566..1416cdc 100755 --- a/tools/muxctrl.py +++ b/tools/muxctrl.py @@ -16,6 +16,7 @@ parser.add_argument("-s", "--setBaudrate", type=int, help="Something like parser.add_argument("-m", "--getMuxLine", default=False, help="Get the current multiplexer control line state.", action='store_true') parser.add_argument("-l", "--setMuxLine", type=int, help="Something like 0 to 7.") parser.add_argument("-r", "--resetToBtldr", default=False, help="Reset the device to the LUFA bootloader.", action='store_true') +parser.add_argument("-d", "--device", type=str, help="The control device like /dev/ttyACM0 or COM3.") ############################################################################### @@ -53,7 +54,8 @@ MUX_MAX_VAL = 7 ############################################################################### -ser = None +ser = None +device = "/dev/ttyACM0" ############################################################################### @@ -308,7 +310,11 @@ def openSerialDevice(d): global ser # Why 115200? Because the host defines the baudrate for the USB serial connection. - ser = serial.Serial(d, 115200, timeout=0) + try: + ser = serial.Serial(d, 115200, timeout=0) + except: + print "ERROR: Can't open the serial device " + device + exit(1) ##### def closeSerialDevice(): @@ -339,7 +345,9 @@ if __name__ == "__main__": timeout = 0 # 1. open serial device or abort - openSerialDevice("/dev/ttyACM0") + if args.device != None: + device = args.device + openSerialDevice(device) # 2. start thread to poll cc_dataReceiverThread() cc_startReceiverThread() diff --git a/tools/readTTYToFile.sh b/tools/readTTYToFile.sh new file mode 100755 index 0000000..12885e5 --- /dev/null +++ b/tools/readTTYToFile.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +TTY_DEV=$1 # or /dev/ttyACM1 +OUT_FILE=$2 + +if [ -z "$TTY_DEV" ]; +then + TTY_DEV=/dev/ttyACM1 +fi + +if [ -z "$OUT_FILE" ]; +then + OUT_FILE="tty_bootup_seq.log" +fi + +echo "Read from "$TTY_DEV" and write to "$OUT_FILE + +while read line; do + if [ "$line" != "EOF" ]; then + echo "$line" >> $OUT_FILE + else + break + fi +done < $TTY_DEV