Commit f1e6d0e5 authored by Matthieu Cattin's avatar Matthieu Cattin

calibr_box: Add exception class.

parent a88ac222
......@@ -22,6 +22,13 @@ calibr_box: Access to calibration box via USB-UART bridge CP2103
"""
class CalibrBoxOperationError(Exception):
def __init__(self, msg):
self.msg = msg
def __str__(self):
return ("Calibration box: %s" %(self.msg))
class CCalibr_box:
def __init__(self, device):
self.cp210x = cp210x_gpio.CCP210x(device)
......@@ -38,7 +45,7 @@ class CCalibr_box:
elif('AWG' == out):
self.cp210x.gpio_set(0x0)
else:
raise Exception('Invalid output selection!')
raise CalibrBoxOperationError("Invalid output selection!")
# Select which channel is connected to AWG
# others are set to Vref for the selected range
......@@ -47,7 +54,7 @@ class CCalibr_box:
if channel >= 1 and channel <= 4:
value = ((4-channel)<<2)
else:
raise Exception('Invalid channel number, must be [1..4]!')
raise CalibrBoxOperationError("Invalid channel number, must be [1..4]!")
#print hex(value)
if('10V' == out):
value += 0x3
......@@ -56,7 +63,7 @@ class CCalibr_box:
elif('100mV' == out):
value += 0x0
else:
raise Exception('Invalid output selection!')
raise CalibrBoxOperationError("Invalid output selection!")
#print hex(value)
self.cp210x.gpio_set(value)
......
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