Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
scouting-demonstrator
SCONE
Commits
0aeea688
Commit
0aeea688
authored
Dec 10, 2020
by
Gaia Grosso
Browse files
Update main.py
parent
e73aaa8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
0aeea688
...
...
@@ -46,9 +46,9 @@ config_dict = {
actions
=
[
"get"
,
"set"
]
def
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
False
):
def
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
0
):
read_32bits
=
ctypes
.
c_uint
(
0
);
isRead
=
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_32bits
))
isRead
=
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_32bits
)
,
ctypes
.
c_uint
(
verbose
)
)
if
isRead
==
-
1
:
print
(
"An error occured while executing C function read_bits"
)
return
-
1
...
...
@@ -58,14 +58,14 @@ def ReadProperty(device, location, offset, width, verbose=False):
print
(
"Read: %s"
%
(
string_32bits
))
string_32bits
=
"{:032b}"
.
format
(
read_32bits
.
value
>>
offset
)
string_out
=
string_32bits
[
-
1
*
width
:]
# remove masked bits
output
=
int
(
string_out
,
2
)
# convert selected string to integer
output
=
int
(
string_out
,
2
)
# convert selected string to integer
if
verbose
:
print
(
"Unmasked result: %i"
%
(
output
))
print
(
"Unmasked result: %i
(%s)
"
%
(
output
,
string_out
))
return
output
def
WriteProperty
(
device
,
location
,
offset
,
width
,
write_value
,
verbose
=
False
):
def
WriteProperty
(
device
,
location
,
offset
,
width
,
write_value
,
verbose
=
0
):
read_value
=
ctypes
.
c_uint
(
0
);
isRead
=
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_value
))
isRead
=
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_value
)
,
ctypes
.
c_uint
(
verbose
)
)
if
isRead
==
-
1
:
print
(
"An error occured while executing C function read_bits"
)
return
-
1
...
...
@@ -77,12 +77,12 @@ def WriteProperty(device, location, offset, width, write_value, verbose=False):
string_write
=
string_read
[:
-
1
*
(
offset
+
width
)]
+
string_write
[
-
1
*
(
offset
+
width
):
-
1
*
offset
]
+
string_read
[
-
1
*
offset
:]
output
=
int
(
string_write
,
2
)
isWritten
=
reg
.
write_bits
(
device
,
location
,
output
)
isWritten
=
reg
.
write_bits
(
device
,
location
,
output
,
ctypes
.
c_uint
(
verbose
)
)
if
isWritten
==
-
1
:
print
(
"An error occured while executing C function write_bits."
)
return
-
1
# Readback as checkout
isReadcheck
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_value
))).
value
isReadcheck
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
,
ctypes
.
byref
(
read_value
)
,
ctypes
.
c_uint
(
verbose
)
)).
value
if
isReadcheck
==
-
1
:
print
(
"An error occured while executing C function read_bits"
)
return
-
1
...
...
@@ -100,7 +100,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
'-a'
,
'--action'
,
type
=
str
,
help
=
"control action"
,
required
=
True
,
choices
=
actions
)
parser
.
add_argument
(
'-p'
,
'--property'
,
type
=
str
,
help
=
"control property"
,
required
=
True
)
parser
.
add_argument
(
'-v'
,
'--value'
,
type
=
str
,
help
=
"new value"
,
required
=
False
)
parser
.
add_argument
(
'-d'
,
'--dump'
,
type
=
bool
,
help
=
"dump messages"
,
required
=
False
,
default
=
False
)
parser
.
add_argument
(
'-d'
,
'--dump'
,
type
=
int
,
help
=
"dump messages"
,
required
=
False
,
default
=
0
)
args
=
parser
.
parse_args
()
board
=
args
.
board
...
...
Write
Preview
Supports
Markdown
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