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

test01: Modify test for compatibility with common modules.

Add proper exception handling.
Add test time measurement.
parent c48ae8d9
......@@ -12,7 +12,7 @@ import sys
import time
import os
# Add common modules location tp path
# Add common modules and libraries location to path
sys.path.append('../../../')
sys.path.append('../../../gnurabbit/python/')
sys.path.append('../../../common/')
......@@ -35,12 +35,13 @@ Note: Requires test00.py to run first to load the firmware!
def main (default_directory='.'):
# Constants declaration
TEST_NB = 1
EXPECTED_BITSTREAM_TYPE = 0x1
start_test_time = time.time()
print "================================================================================"
print "Test01 start\n"
print "Test%02d start\n" % TEST_NB
# SPEC object declaration
print "Loading hardware access library and opening device.\n"
......@@ -58,22 +59,18 @@ def main (default_directory='.'):
except FmcAdc100mOperationError as e:
raise PtsCritical("Mezzanine init failed, test stopped: %s" % e)
# Read unique ID and print to log
unique_id = fmc.get_unique_id()
if(unique_id == -1):
raise PtsError ("Can't read DS18D20 1-wire thermometer.")
else:
print('Unique ID: %.12X') % unique_id
# Read temperatur and print to log
temp = fmc.get_temp()
print('FMC temperature: %3.3f°C') % temp
if((unique_id & 0xFF) != FAMILY_CODE):
family_code = unique_id & 0xFF
print('family code: 0x%.8X') % family_code
raise PtsError ("1-wire thermometer has the wrong family code:0x.2X expected:0x%.2X" % family_code,FAMILY_CODE)
# Print mezzanine unique ID and temperature to log
try:
fmc.print_unique_id()
fmc.print_temp()
except FmcAdc100mOperationError as e:
raise PtsError("Mezzanine onewire test failed: " % 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__' :
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