Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Production Test Suite
Commits
f1e6d0e5
Commit
f1e6d0e5
authored
May 30, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calibr_box: Add exception class.
parent
a88ac222
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
calibr_box.py
test/fmcadc100m14b4cha/python/calibr_box.py
+10
-3
No files found.
test/fmcadc100m14b4cha/python/calibr_box.py
View file @
f1e6d0e5
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment