コード例 #1
0
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'
コード例 #2
0
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'
コード例 #3
0
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])
コード例 #4
0
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'
コード例 #5
0
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'
コード例 #6
0
#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()
コード例 #7
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
# $HeadURL$
#
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')
gt.expect(ser, ['[#]'], 5)
#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()
texpect = time.mktime(dt.timetuple())
コード例 #8
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
# $HeadURL$
#

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'], 10)
if wireless == -1:
    gt.fail([ser])
ser.close()
print 'PASSED'