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
d8fc0a49
Commit
d8fc0a49
authored
Dec 10, 2020
by
Gaia Grosso
Browse files
Update main.py
parent
acbe93ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
d8fc0a49
...
...
@@ -100,6 +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
(
'-f'
,
'--filelog'
,
type
=
str
,
help
=
"logfile"
,
required
=
False
)
parser
.
add_argument
(
'-d'
,
'--dump'
,
type
=
int
,
help
=
"dump messages"
,
required
=
False
,
default
=
0
)
args
=
parser
.
parse_args
()
...
...
@@ -112,6 +113,8 @@ if __name__ == '__main__':
action
=
args
.
action
value
=
int
(
args
.
value
)
verbose
=
args
.
dump
filelog
=
args
.
filelog
output
=
0
# exceptions:
if
offset
>
30
:
print
(
"Offset value %i is out of range 0-30. Check the configuration file."
%
(
offset
))
...
...
@@ -134,17 +137,29 @@ if __name__ == '__main__':
exit
()
else
:
writevalue
=
ctypes
.
c_uint
(
value
)
#unsigned int (32 bits)
isWritten
=
WriteProperty
(
device
,
location
,
offset
,
width
,
writevalue
,
verbose
=
verbose
)
if
isWritten
==
-
1
:
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
))
elif
action
==
"get"
:
isRead
=
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
verbose
)
if
isRead
==
-
1
:
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
,
isRead
))
print
(
'Get property %s from location %s on %s: %i'
%
(
prop
,
location
,
board
,
output
))
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
(
"output: %i
\n
"
%
(
output
))
f
.
close
()
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