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
4c8a9e06
Commit
4c8a9e06
authored
Jun 04, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test21: Uses common modules, added exception handling.
parent
19efb5a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
test21.py
test/fmcadc100m14b4cha/python/test21.py
+29
-15
No files found.
test/fmcadc100m14b4cha/python/test21.py
View file @
4c8a9e06
...
@@ -5,17 +5,25 @@
...
@@ -5,17 +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: 4/6/2012
# Import system modules
import
sys
import
sys
import
rr
import
time
import
time
import
os
import
os
import
re
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
*
from
ptsexcept
import
*
import
rr
import
cp210x_eeprom
# Import specific modules
from
cp210x_eeprom
import
*
"""
"""
...
@@ -39,7 +47,7 @@ CALIBR_RANGES = ['10V', '1V', '100mV']
...
@@ -39,7 +47,7 @@ CALIBR_RANGES = ['10V', '1V', '100mV']
def
input_calibr_data
(
range_str
):
def
input_calibr_data
(
range_str
):
while
(
True
):
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'
pattern
=
r'\b[0-9]\.[0-9]{8}\b'
if
re
.
search
(
pattern
,
calibr_string
):
if
re
.
search
(
pattern
,
calibr_string
):
return
calibr_string
return
calibr_string
...
@@ -49,20 +57,26 @@ def input_calibr_data(range_str):
...
@@ -49,20 +57,26 @@ def input_calibr_data(range_str):
def
main
():
def
main
():
box_eeprom
=
cp210x_eeprom
.
CCP210x_Eeprom
(
"
%
X"
%
BOX_USB_VENDOR_ID
,
"
%
X"
%
BOX_USB_PRODUCT_ID
)
# Ask user to input calibration data
try
:
calibr_data
=
{}
for
range_str
in
CALIBR_RANGES
:
box_eeprom
=
CCP210x_Eeprom
(
"
%
X"
%
BOX_USB_VENDOR_ID
,
"
%
X"
%
BOX_USB_PRODUCT_ID
)
calibr_data
[
range_str
]
=
input_calibr_data
(
range_str
)
# Ask user to input calibration data
calibr_data
=
{}
for
range_str
in
CALIBR_RANGES
:
calibr_data
[
range_str
]
=
input_calibr_data
(
range_str
)
# Write calibration data to cp210x EEPROM
box_eeprom
.
set_calibr_data
(
calibr_data
)
# Write calibration data to cp210x EEPROM
print
"Readback calibration data from cp210x EEPROM."
box_eeprom
.
set_calibr_data
(
calibr_data
)
calibr_data
=
box_eeprom
.
get_calibr_data
()
for
range_str
,
value
in
calibr_data
.
iteritems
():
print
"
%5
s range calibration voltage is:
%
s V"
%
(
range_str
,
value
)
print
"Readback calibration data from cp210x EEPROM."
except
(
CP210xEepromOperationError
)
as
e
:
calibr_data
=
box_eeprom
.
get_calibr_data
()
raise
PtsError
(
"Test failed:
%
s"
%
e
)
for
range_str
,
value
in
calibr_data
.
iteritems
():
print
"
%5
s range calibration voltage is:
%
s V"
%
(
range_str
,
value
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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