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
a193fb9b
Commit
a193fb9b
authored
Dec 10, 2020
by
Gaia Grosso
Browse files
Update main.py
parent
d8fc0a49
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
a193fb9b
...
...
@@ -128,19 +128,41 @@ if __name__ == '__main__':
if
action
==
"set"
:
if
value
==
None
:
print
(
"action 'set' requires the optional argument --value (-v)."
)
exit
()
if
filelog
:
print
(
"Save log at %s"
%
(
filelog
))
f
=
open
(
filelog
,
"w"
)
f
.
write
(
"board: %s
\n
"
%
(
device
))
f
.
write
(
"property: %s
\n
"
%
(
prop
))
f
.
write
(
"location: %s
\n
"
%
(
location
))
f
.
write
(
"offset: %i
\n
"
%
(
offset
))
f
.
write
(
"width: %i
\n
"
%
(
width
))
f
.
write
(
"action: %s
\n
"
%
(
action
))
f
.
write
(
"error: action 'set' requires the optional argument --value (-v)."
)
f
.
close
()
exit
()
nbits_allowed
=
width
# number of allowed bits
nbits_write
=
value
.
bit_length
()
# number of bits needed
if
nbits_write
>
nbits_allowed
:
print
(
"Overflow error! value %s doesn't fit in the allowed memory location."
%
(
args
.
value
))
if
filelog
:
print
(
"Save log at %s"
%
(
filelog
))
f
=
open
(
filelog
,
"w"
)
f
.
write
(
"board: %s
\n
"
%
(
device
))
f
.
write
(
"property: %s
\n
"
%
(
prop
))
f
.
write
(
"location: %s
\n
"
%
(
location
))
f
.
write
(
"offset: %i
\n
"
%
(
offset
))
f
.
write
(
"width: %i
\n
"
%
(
width
))
f
.
write
(
"action: %s
\n
"
%
(
action
))
f
.
write
(
"error: overflow error! value %s doesn't fit in the allowed memory location."
%
(
args
.
value
))
f
.
close
()
exit
()
else
:
writevalue
=
ctypes
.
c_uint
(
value
)
#unsigned int (32 bits)
output
=
WriteProperty
(
device
,
location
,
offset
,
width
,
writevalue
,
verbose
=
verbose
)
if
output
==
-
1
:
print
(
'The value could not be updated.'
)
exit
()
else
:
print
(
'Set property %s from location %s on %s: %i'
%
(
prop
,
location
,
board
,
writevalue
.
value
))
...
...
@@ -148,7 +170,6 @@ if __name__ == '__main__':
output
=
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
verbose
)
if
output
==
-
1
:
print
(
'The register could not be read.'
)
exit
()
else
:
print
(
'Get property %s from location %s on %s: %i'
%
(
prop
,
location
,
board
,
output
))
...
...
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