def serial_test(port): #open serial 1 serial_one=serial.Serial(port='COM7', baudrate=115200, timeout=1) #login login = gt.login(serial_one) if not login: gt.fail([serial_one]) #open serial 4 serial_two=serial.Serial(port='COM9', baudrate=115200, timeout=1) #start serial test serial_one.write('tests/gumstix_serial_test.sh %s\r' % port) #1234 written from ser 1 gt.expect(serial_one, ['1234'], 10) #expect 1234 echoed on ser 2 read = gt.expect(serial_two, ['1234'], 10) #wait for ser 1 to listen gt.expect(serial_one, ['cat'], 10) serial_two.write('4321\r') #expect 4321 echoed on ser 1 write = gt.expect(serial_one, ['4321'], 10) #end the test with ctrl-c serial_one.write('\x03') gt.expect(serial_one, ['[#]'], 5) #close the ports when done serial_one.close() serial_two.close() if read == 0 and write == 0: print 'PASSED' else: print 'FAILED'
def serial_test(port): #open serial 1 serial_one = serial.Serial(port='COM7', baudrate=115200, timeout=1) #login login = gt.login(serial_one) if not login: gt.fail([serial_one]) #open serial 4 serial_two = serial.Serial(port='COM9', baudrate=115200, timeout=1) #start serial test serial_one.write('tests/gumstix_serial_test.sh %s\r' % port) #1234 written from ser 1 gt.expect(serial_one, ['1234'], 10) #expect 1234 echoed on ser 2 read = gt.expect(serial_two, ['1234'], 10) #wait for ser 1 to listen gt.expect(serial_one, ['cat'], 10) serial_two.write('4321\r') #expect 4321 echoed on ser 1 write = gt.expect(serial_one, ['4321'], 10) #end the test with ctrl-c serial_one.write('\x03') gt.expect(serial_one, ['[#]'], 5) #close the ports when done serial_one.close() serial_two.close() if read == 0 and write == 0: print 'PASSED' else: print 'FAILED'
def serial_loopback(gtport): #open serial one and login ser1 = serial.Serial(port='COM7', baudrate=115200, timeout=1) login = gt.login(ser1) if not login: gt.fail([ser1]) #list of baudrates to test bauds=[4800, 9600, 19200, 115200, 460800] for baud in bauds: #run the loopback test on the given port at the current baud ser1.write('tests/gumstix_serial_loopback_test.sh %s %i' % (gtport, baud)) #estimate of how long it should take to transfer the ~ 1MB file time_est = 1024*1024*10 / baud #expect a result within 1.5 times the estimate sertest = gt.expect(ser1, ['PASSED', 'FAILED'], time_est*1.5) #if any baud fails or doesn't return within 1.5 times the estimate, failed test if sertest == 1,-1: gt.fail([ser1])
def serial_loopback(gtport): #open serial one and login ser1 = serial.Serial(port='COM7', baudrate=115200, timeout=1) if not gt.login(ser1): gt.fail(ser1) #list of baudrates to test #bauds=[4800, 9600, 19200, 115200] bauds = [115200] for baud in bauds: #run the loopback test on the given port at the current baud ser1.write('tests/gumstix_serial_loopback_test.sh %s %i\r' % (gtport, baud)) #estimate of how long it should take to transfer the ~ 1MB file time_est = 1024*1024*10 / baud #expect a result within 1.5 times the estimate sertest = gt.expect(ser1, ['PASSED', 'FAILED'], time_est*1.5) #if any baud fails or doesn't return within 1.5 times the estimate, failed test if (sertest == 1) | (sertest == -1): print 'failing' gt.fail(ser1) print 'pass on baudrate: %i' % baud time.sleep(.5) ser1.close() print 'PASSED'
def serial_loopback(gtport): #open serial one and login ser1 = serial.Serial(port='COM7', baudrate=115200, timeout=1) if not gt.login(ser1): gt.fail(ser1) #list of baudrates to test #bauds=[4800, 9600, 19200, 115200] bauds = [115200] for baud in bauds: #run the loopback test on the given port at the current baud ser1.write('tests/gumstix_serial_loopback_test.sh %s %i\r' % (gtport, baud)) #estimate of how long it should take to transfer the ~ 1MB file time_est = 1024 * 1024 * 10 / baud #expect a result within 1.5 times the estimate sertest = gt.expect(ser1, ['PASSED', 'FAILED'], time_est * 1.5) #if any baud fails or doesn't return within 1.5 times the estimate, failed test if (sertest == 1) | (sertest == -1): print 'failing' gt.fail(ser1) print 'pass on baudrate: %i' % baud time.sleep(.5) ser1.close() print 'PASSED'
#dependencies="00a" __author__ = 'chet' # # $Id$ # import gumtools as gt import serial import datetime, time #open serial one ser =serial.Serial(port='COM7', baudrate='115200', timeout=1) #login if not gt.login(ser): gt.fail(ser) #get the UTC time and convert to a usable string t=datetime.datetime.utcnow() tstr = t.strftime('%d %b %Y %H:%M:%S') #set the date ser.write('date -s "%s"\r' % tstr) gt.expect(ser, ['[#]'], 5) #flush it ser.write('hwclock -w\r') clockset = gt.expect(ser, ['Cannot access', '[#]'], 5) if not clockset: gt.fail(ser) #reboot and login again ser.write('reboot\r') gt.login(ser) #get the date again (not UTC, because time.mktime seems to assume the # given time tuple is local time when converting to seconds since epoch dt = datetime.datetime.now()
#dependencies="" __author__ = 'chet' # # $Id$ # import serial import gumtools as gt #open serial port to Gumstix Serial 1 serial_one=serial.Serial(port='COM7', baudrate=115200, timeout=1) #log into board login = gt.login(serial_one) serial_one.close() print 'PASSED' if login else 'FAILED'
#dependencies="00a" __author__ = 'chet' # # $Id$ # import gumtools as gt import serial import sys ser = serial.Serial(port='COM7', baudrate=115200, timeout=1) login = gt.login(ser) if not login: gt.fail(ser) ser.write('iwlist scanning\r') wireless = gt.expect(ser, ['acommsnet', 'Atlantic', 'WHOI_Meeting', 'Arctic'], 10) gt.expect(ser, ['[#]'], 10) if wireless == -1: gt.fail(ser) ser.close() print 'PASSED'
#dependencies="" __author__ = 'chet' # # $Id$ # import serial import gumtools as gt #open serial port to Gumstix Serial 1 serial_one = serial.Serial(port='COM7', baudrate=115200, timeout=1) #log into board login = gt.login(serial_one) serial_one.close() print 'PASSED' if login else 'FAILED'
#dependencies="00a" __author__ = 'chet' # # $Id$ # import gumtools as gt import serial import sys ser = serial.Serial(port='COM7', baudrate=115200, timeout=1) login = gt.login(ser) if not login: gt.fail(ser) ser.write('iwlist scanning\r') wireless = gt.expect(ser, ['acommsnet', 'Atlantic', 'WHOI_Meeting', 'Arctic'], 10) gt.expect(ser, ['[#]'], 10) if wireless == -1: gt.fail(ser) ser.close() print 'PASSED'
#dependencies="00a" __author__ = 'chet' # # $Id$ # import gumtools as gt import serial #open the port and login ser = serial.Serial(port='COM7', baudrate=115200, timeout=1) if not gt.login(ser): gt.fail(ser) #find/replace the watchdog file using sed ser.write("sed -i 's/run_watchdog=1/run_watchdog=0/g' /etc/default/watchdog\r") if gt.expect(ser, ['[#]'], 5): gt.fail(ser) #reboot ser.write('reboot\r') if not gt.login(ser): gt.fail(ser) #expect it to reboot on its own (wait 10 mins plus the ~2 it'd take to reboot) if gt.expect(ser, ['login:'******'s/run_watchdog=0/run_watchdog=1/g' /etc/default/watchdog\r") if gt.expect(ser, ['[#]'], 5):