Commit 2b12c75a authored by Matthieu Cattin's avatar Matthieu Cattin

test03: Uses common modules, added exception handling.

parent c75f8766
......@@ -5,15 +5,25 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 29/5/2012
# Import system modules
import sys
import rr
import time
import os
# Add common modules and libraries location to path
sys.path.append('../../../')
sys.path.append('../../../gnurabbit/python/')
sys.path.append('../../../common/')
# Import common modules
from ptsexcept import *
import rr
import fmc_adc
# Import specific modules
from fmc_adc_spec import *
from fmc_adc import *
"""
......@@ -25,80 +35,101 @@ Note: Requires test00.py to run first to load the firmware!
def main (default_directory='.'):
"""
path_fpga_loader = '../../../gnurabbit/user/fpga_loader';
path_firmware = '../firmwares/spec_fmcadc100m14b4cha.bin';
firmware_loader = os.path.join(default_directory, path_fpga_loader)
bitstream = os.path.join(default_directory, path_firmware)
print firmware_loader + ' ' + bitstream
os.system( firmware_loader + ' ' + bitstream )
time.sleep(2);
"""
# Objects declaration
spec = rr.Gennum() # bind to the SPEC board
fmc = fmc_adc.CFmcAdc100Ms(spec)
# Standard in/out temporary redirection
tmp_stdout = sys.stdout;
sys.stdout = sys.__stdout__;
tmp_stdin = sys.stdin;
sys.stdin = sys.__stdin__;
# Initialize error variable, disable triggers and make sure no acquisition is running
error = [0, 0]
fmc.set_trig_config(1, 0, 0, 0, 0, 0, 0)
fmc.stop_acq()
############################################################################
# Test LEDs ON
fmc.trig_led(1)
fmc.acq_led(1)
ask = "";
while ((ask != "Y") and (ask != "N")) :
print "-------------------------------------------------------------"
ask = raw_input("Are the front panel LEDs (TRIG and ACQ) switched ON? [y,n]")
ask = ask.upper()
#print "-------------------------------------------------------------"
print " "
if (ask == "N"):
# LED ON fail
error[0] += 1
############################################################################
# Test LEDs OFF
fmc.trig_led(0)
fmc.acq_led(0)
ask = "";
while ((ask != "Y") and (ask != "N")) :
print "-------------------------------------------------------------"
ask = raw_input("Are the front panel LEDs (TRIG and ACQ) switched OFF? [y,n]")
ask = ask.upper()
#print "-------------------------------------------------------------"
print " "
if (ask == "N"):
# LED OFF fail
error[0] += 1
# Standard in/out redirection
sys.stdout = tmp_stdout;
sys.stdin = tmp_stdin;
# Check if an error occured during LED test
if (error != [0]*2):
if(error[0] != 0):
print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.")
if(error[1] != 0):
print("One or both LEDs not switching OFF. Check for short-cut.")
raise PtsError('An error occured during LEDs test, check log for details.')
else:
print('LEDs are working ok.')
# Constants declaration
TEST_NB = 3
EXPECTED_BITSTREAM_TYPE = 0x1
start_test_time = time.time()
print "================================================================================"
print "Test%02d start\n" % TEST_NB
# SPEC object declaration
print "Loading hardware access library and opening device.\n"
spec = rr.Gennum()
# Carrier object declaration (SPEC board specific part)
# Used to check that the firmware is loaded.
try:
carrier = CFmcAdc100mSpec(spec, EXPECTED_BITSTREAM_TYPE)
except FmcAdc100mSpecOperationError as e:
raise PtsCritical("Carrier init failed, test stopped: %s" % e)
# Mezzanine object declaration (FmcAdc100m14b4cha board specific part)
try:
fmc = CFmcAdc100m(spec)
except FmcAdc100mOperationError as e:
raise PtsCritical("Mezzanine init failed, test stopped: %s" % e)
try:
# Standard in/out temporary redirection
tmp_stdout = sys.stdout;
sys.stdout = sys.__stdout__;
tmp_stdin = sys.stdin;
sys.stdin = sys.__stdin__;
# Initialize error variable, disable triggers and make sure no acquisition is running
error = [0, 0]
fmc.set_trig_config(1, 0, 0, 0, 1, 0, 0)
fmc.stop_acq()
#==================================================
# Test LEDs ON
fmc.trig_led(1)
fmc.acq_led(1)
ask = "";
while ((ask != "Y") and (ask != "N")) :
print "-------------------------------------------------------------"
ask = raw_input("Are the front panel LEDs (TRIG and ACQ) switched ON? [y,n]")
ask = ask.upper()
#print "-------------------------------------------------------------"
print " "
if (ask == "N"):
# LED ON fail
error[0] += 1
#==================================================
# Test LEDs OFF
fmc.trig_led(0)
fmc.acq_led(0)
ask = "";
while ((ask != "Y") and (ask != "N")) :
print "-------------------------------------------------------------"
ask = raw_input("Are the front panel LEDs (TRIG and ACQ) switched OFF? [y,n]")
ask = ask.upper()
#print "-------------------------------------------------------------"
print " "
if (ask == "N"):
# LED OFF fail
error[1] += 1
# Restore standard in/out
sys.stdout = tmp_stdout;
sys.stdin = tmp_stdin;
# Check if an error occured during LED test
if (error != [0]*2):
if(error[0] != 0):
print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.")
if(error[1] != 0):
print("One or both LEDs not switching OFF. Check for short-cut.")
raise PtsError('An error occured during LEDs test, check log for details.')
else:
print('LEDs are working ok.')
except FmcAdc100mOperationError as e:
raise PtsError("Test failed: %s" % e)
print ""
print "==> End of test%02d" % TEST_NB
print "================================================================================"
end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
if __name__ == '__main__' :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment