Пример #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'
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'
Пример #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 uuid

#open the port and login to gumstix
ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
#create a directory to mount the card to
ser.write('mkdir /media/sd\r')
gt.expect(ser, ['[#]'], 3)

#3 mounts and unmounts
for mounts in xrange(3):
    #mount the sdcard
    ser.write('mount /dev/mmcblk1p1 /media/sd\r')
    mnt = gt.expect(ser, ['mount:', '[#]'], 5)
    if (mnt == 0) | (mnt == -1):
        print 'There was an error while mounting the sd card, please verify an SDXC card is mounted in the secondary slot.'
        gt.fail(ser)
    #random file name to save random data
    gumfile = uuid.uuid4().hex
    #write the first MB of data from /dev/urandom to the random file
    ser.write('head -c 1048576 /dev/urandom > %s\r' % gumfile)
    if gt.expect(ser, ['[#]'], 15):
        print 'There was an error while copying data from /dev/urandom to a file on disk. Try rebooting or editing this' \
Пример #7
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'
Пример #8
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
#
import gumtools as gt
import serial

ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)

ser.write('tests/alsa_setup.sh\r')
gt.expect(ser, ['[#]'], 5)
ser.write('tests/gumstix_audio_test.sh\r')
gt.expect(ser, ['[#]'], 15)
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):
Пример #10
0
        ser.write('echo out > /gpio/boardio%i/direction\r' % (i+1))
        sleep(1)
        ser.write('echo %i > /gpio/boardio%i/value\r' % (val, i+1))
        sleep(1)
        #read value on LJ
        ljread = int(ljm.eReadName(lj, DIO))
        print 'LJRead on GPIO %i expecting %i got %i' % (i, val, ljread)
        if ljread != val:
            gpios[i] = False
        ser.write('echo in > /gpio/boardio%i/direction\r' % (i+1))
        #configure LJ to output
        ljm.eWriteName(lj, DIO, val)
        sleep(1)
        #read value on gumstix
        ser.write('cat /gpio/boardio%i/value\r' % (i+1))
        gtread = gt.expect(ser, ['0', '1'], 5)
        print 'GTRead on GPIO %i expecting %i got %i' % (i, val, gtread)
        if gtread != val:
            gpios[i] = False
#pass if all passed
success = True
#print results for each GPIO
for ind, gpio in enumerate(gpios):
    if gpio:
        result = 'passed'
    else:
        result = 'failed'
        success = False
    print 'GPIO %i %s' % (ind, result)
#fail if any one failed
if not success:
Пример #11
0
#
# $Id$
#
import gumtools as gt
import serial
import re
import operator

#open the port and login
ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
#start the adc test
ser.write("tests/gumstix_adc_test.sh\r")
#wait until the only output will be adc reads
gt.expect(ser, ["gumstix_adc_test.sh"], 10)
#collect all lines of adc reads into buff
buff = ser.read(128).decode('utf-8')
endread = re.search('[a-zA-Z]', buff)
while not endread:
    buff += ser.read(128).decode('utf-8')
    endread = re.search('[a-zA-Z]', buff)
#ignore anything after the adc reads
buff = buff[:endread.start()]
#now check to make sure each column of the reads changes at some point
firstvals = []
bools = []
for line in buff:
    for ind,val in enumerate(line.split(' ')):
        #first line initialize the boolean and firstval lists
        if len(bools) <= ind:
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
# $HeadURL$
#
import gumtools as gt
import serial

ser = serial.Serial(port='COM7', baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail([ser])
ser.write('ping google.com\r')
ping = gt.expect(ser, ['64 bytes from'], 10)
if ping == -1:
    gt.fail([ser])
ser.write('\x03')
gt.expect(ser, ['[#]'], 10)
ser.write('wget http://www.ourdocuments.gov/document_data/pdf/doc_013.pdf\r')
dl = gt.expect(ser, ['saved'], 15)
if dl == -1:
    gt.fail([ser])
ser.close()
print 'PASSED'
Пример #13
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
#
import gumtools as gt
import serial
import uuid

#open the port and login to gumstix
ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
#create a directory to mount the card to
ser.write('mkdir /media/sd\r')
gt.expect(ser, ['[#]'],3)

#3 mounts and unmounts
for mounts in xrange(3):
    #mount the sdcard
    ser.write('mount /dev/mmcblk1p1 /media/sd\r')
    mnt = gt.expect(ser, ['mount:', '[#]'], 5)
    if (mnt == 0) | (mnt == -1):
        print 'There was an error while mounting the sd card, please verify an SDXC card is mounted in the secondary slot.'
        gt.fail(ser)
    #random file name to save random data
    gumfile = uuid.uuid4().hex
    #write the first MB of data from /dev/urandom to the random file
    ser.write('head -c 1048576 /dev/urandom > %s\r' % gumfile)
    if gt.expect(ser, ['[#]'], 15):
        print 'There was an error while copying data from /dev/urandom to a file on disk. Try rebooting or editing this' \
#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'
Пример #15
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
#
import gumtools as gt
import serial

ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
ser.write('tests/gumstix_power_test.sh\r')
gt.expect(ser, ['[#]'], 180)
ser.write('reboot')
#FILL IN TEST HERE
ser.close()
print 'PASSED'
Пример #16
0
#
# $Id$
#
import gumtools as gt
import serial
import re
import operator

#open the port and login
ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
#start the adc test
ser.write("tests/gumstix_adc_test.sh\r")
#wait until the only output will be adc reads
gt.expect(ser, ["gumstix_adc_test.sh"], 10)
#collect all lines of adc reads into buff
buff = ser.read(128).decode('utf-8')
endread = re.search('[a-zA-Z]', buff)
while not endread:
    buff += ser.read(128).decode('utf-8')
    endread = re.search('[a-zA-Z]', buff)
#ignore anything after the adc reads
buff = buff[:endread.start()]
#now check to make sure each column of the reads changes at some point
firstvals = []
bools = []
for line in buff:
    for ind, val in enumerate(line.split(' ')):
        #first line initialize the boolean and firstval lists
        if len(bools) <= ind:
#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'
Пример #18
0
#dependencies="00a,02e"
#This test requires a usb cable connecting USB OTG to USB host on the testbox and a mounted USB card in the board 2nd slot
#as well as the 'gumstix_usb_test.sh' bash script on the board
__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)
#run the usb test and check the output
ser.write('tests/gumstix_usb_test.sh\r')
usbtest = gt.expect(ser, ['PASSED', 'FAILED'], 20)
#report accordingly
if usbtest == -1:
    print 'An unanticipated error occurred while testing the USB connection, please reseat the SD card,' \
          ' check all cables and reboot the board.'
    gt.fail(ser)
elif usbtest == 1:
    print 'Writing a ~1MB file over USB host/OTG connection failed, please reseat the SD card,' \
          ' check all cables and reboot the board.'
    gt.fail(ser)
else:
    ser.close()
    print 'PASSED'
#
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())
#set up a range of 100 seconds on either side
trange = [texpect - 100, texpect, texpect + 100]
#trim down to match up to the hundred seconds
for ind, secs in enumerate(trange):
    secs = str(secs)[:-4]
Пример #20
0
        ser.write('echo out > /gpio/boardio%i/direction\r' % (i + 1))
        sleep(1)
        ser.write('echo %i > /gpio/boardio%i/value\r' % (val, i + 1))
        sleep(1)
        #read value on LJ
        ljread = int(ljm.eReadName(lj, DIO))
        print 'LJRead on GPIO %i expecting %i got %i' % (i, val, ljread)
        if ljread != val:
            gpios[i] = False
        ser.write('echo in > /gpio/boardio%i/direction\r' % (i + 1))
        #configure LJ to output
        ljm.eWriteName(lj, DIO, val)
        sleep(1)
        #read value on gumstix
        ser.write('cat /gpio/boardio%i/value\r' % (i + 1))
        gtread = gt.expect(ser, ['0', '1'], 5)
        print 'GTRead on GPIO %i expecting %i got %i' % (i, val, gtread)
        if gtread != val:
            gpios[i] = False
#pass if all passed
success = True
#print results for each GPIO
for ind, gpio in enumerate(gpios):
    if gpio:
        result = 'passed'
    else:
        result = 'failed'
        success = False
    print 'GPIO %i %s' % (ind, result)
#fail if any one failed
if not success:
Пример #21
0
#
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()
texpect = time.mktime(dt.timetuple())
#set up a range of 100 seconds on either side
trange = [texpect-100, texpect, texpect+100]
#trim down to match up to the hundred seconds
Пример #22
0
#dependencies="00a"
__author__ = 'chet'
#
# $Id$
#
import gumtools as gt
import serial

ser = serial.Serial(port="COM7", baudrate=115200, timeout=1)
if not gt.login(ser):
    gt.fail(ser)
#write all commented lines to a temp file
ser.write("sed -n '/#/p' /etc/udev/rules.d/70-persistent-net.rules > /etc/udev/rules.d/tmp\r")
if gt.expect(ser, ['[#]'], 10):
    gt.fail(ser)
#mv the temp file to the original
ser.write('mv /etc/udev/rules.d/tmp /etc/udev/rules.d/70-persistent-net.rules\r')
if gt.expect(ser, ['[#]'], 5):
    gt.fail(ser)
ser.write("find /etc/udev/rules.d/ -type f -not -name '70-persistent-net.rules' | xargs rm\r")
if gt.expect(ser, ['[#]'], 5):
    gt.fail(ser)
ser.close()
print 'PASSED'