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

test03: Uses common modules, added exception handling.

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