Commit 4c8a9e06 authored by Matthieu Cattin's avatar Matthieu Cattin

test21: Uses common modules, added exception handling.

parent 19efb5a9
......@@ -5,17 +5,25 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 4/6/2012
# Import system modules
import sys
import rr
import time
import os
import re
from ctypes import *
# 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 cp210x_eeprom
# Import specific modules
from cp210x_eeprom import *
"""
......@@ -39,7 +47,7 @@ CALIBR_RANGES = ['10V', '1V', '100mV']
def input_calibr_data(range_str):
while(True):
calibr_string = raw_input("Enter calibration voltage for "+range_str+" range (in volts, max 10 char): ")
calibr_string = raw_input("Enter calibration voltage for "+range_str+" range (in volts, format 0.00000000): ")
pattern = r'\b[0-9]\.[0-9]{8}\b'
if re.search(pattern, calibr_string):
return calibr_string
......@@ -49,7 +57,10 @@ def input_calibr_data(range_str):
def main ():
box_eeprom = cp210x_eeprom.CCP210x_Eeprom("%X"%BOX_USB_VENDOR_ID, "%X"%BOX_USB_PRODUCT_ID)
try:
box_eeprom = CCP210x_Eeprom("%X"%BOX_USB_VENDOR_ID, "%X"%BOX_USB_PRODUCT_ID)
# Ask user to input calibration data
calibr_data = {}
......@@ -64,6 +75,9 @@ def main ():
for range_str, value in calibr_data.iteritems():
print "%5s range calibration voltage is: %s V" % (range_str, value)
except(CP210xEepromOperationError) as e:
raise PtsError("Test failed: %s" % e)
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