Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-lib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
adc-lib
Commits
3af1edd7
Commit
3af1edd7
authored
Aug 07, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tst: add offset test
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
23f3faf5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
test_adc_getter_setter.py
pytest/fmc-adc-100m14b4cha/test_adc_getter_setter.py
+25
-0
No files found.
pytest/fmc-adc-100m14b4cha/test_adc_getter_setter.py
View file @
3af1edd7
...
...
@@ -4,6 +4,7 @@ SPDX-FileCopyrightText: 2020 CERN
"""
import
pytest
import
ctypes
import
random
from
PyAdcLib
import
PyAdcConf
...
...
@@ -22,3 +23,27 @@ class TestAdcGetterSetter(object):
conf_rb
.
mask_set
(
PyAdcConf
.
ADC_CONF_CHN_TERMINATION
)
adc100m14b4cha
.
retrieve_config
(
conf_rb
)
assert
conf
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_TERMINATION
)
==
conf_rb
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_TERMINATION
)
@
pytest
.
mark
.
parametrize
(
"offset"
,
range
(
-
5000000
,
5000000
+
1
,
100000
))
@
pytest
.
mark
.
parametrize
(
"channel"
,
range
(
4
))
def
test_adc_offset
(
self
,
adc100m14b4cha
,
offset
,
channel
):
"Test that we can read/write offset on all channels"
conf
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_CHN
,
channel
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
,
offset
)
assert
conf
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
)
==
ctypes
.
c_uint32
(
offset
)
.
value
adc100m14b4cha
.
apply_config
(
conf
,
0
)
conf_rb
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_CHN
,
channel
)
conf_rb
.
mask_set
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
)
adc100m14b4cha
.
retrieve_config
(
conf_rb
)
assert
conf
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
)
==
conf_rb
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
)
@
pytest
.
mark
.
parametrize
(
"offset"
,
[
-
5000001
,
5000001
])
@
pytest
.
mark
.
parametrize
(
"channel"
,
range
(
4
))
def
test_adc_offset_invalid
(
self
,
adc100m14b4cha
,
offset
,
channel
):
"Test that we can read/write offset on all channels"
conf
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_CHN
,
channel
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
,
offset
)
assert
conf
.
value_get
(
PyAdcConf
.
ADC_CONF_CHN_OFFSET
)
==
ctypes
.
c_uint32
(
offset
)
.
value
with
pytest
.
raises
(
OSError
):
adc100m14b4cha
.
apply_config
(
conf
,
0
)
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