Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SCONE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scouting-demonstrator
SCONE
Commits
dd4f69a1
Commit
dd4f69a1
authored
4 years ago
by
Gaia Grosso
Browse files
Options
Downloads
Patches
Plain Diff
Update main.py
parent
a684f56f
No related branches found
No related tags found
1 merge request
!1
Main
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+21
-1
21 additions, 1 deletion
main.py
with
21 additions
and
1 deletion
main.py
+
21
−
1
View file @
dd4f69a1
...
@@ -41,6 +41,19 @@ config_dict = {
...
@@ -41,6 +41,19 @@ config_dict = {
actions
=
[
"
get
"
,
"
set
"
]
actions
=
[
"
get
"
,
"
set
"
]
def
CheckMask
(
mask_32bits
):
list_32mask
=
[
int
(
bit
)
for
bit
in
mask_32bits
]
variations
=
[
x
[
i
]
-
x
[
i
+
1
]
for
i
in
range
(
len
(
list_32mask
)
-
1
)]
n_variations
=
sum
([
abs
(
x
)
for
x
in
variations
])
if
n_variations
>
2
:
return
False
elif
n_variations
==
2
:
for
x
in
variantions
:
if
x
<
0
:
return
True
if
x
>
0
:
return
False
else
:
return
True
def
ReadProperty
(
device
,
location
,
mask_32bits
,
verbose
=
False
):
def
ReadProperty
(
device
,
location
,
mask_32bits
,
verbose
=
False
):
read_32bits
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
))
read_32bits
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
))
string_32bits
=
"
{:032b}
"
.
format
(
read_32bits
.
value
)
string_32bits
=
"
{:032b}
"
.
format
(
read_32bits
.
value
)
...
@@ -83,7 +96,7 @@ def WriteProperty(device, location, string_mask, write_value):
...
@@ -83,7 +96,7 @@ def WriteProperty(device, location, string_mask, write_value):
# Readback as checkout
# Readback as checkout
read_value_new
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
))
read_value_new
=
ctypes
.
c_uint
(
reg
.
read_bits
(
device
,
location
))
if
read_value_new
==
read_value
:
return
True
if
read_value_new
==
output
:
return
True
else
:
return
False
else
:
return
False
...
@@ -113,6 +126,12 @@ if __name__ == '__main__':
...
@@ -113,6 +126,12 @@ if __name__ == '__main__':
bitmask
=
config_dict
[
board
][
"
property
"
][
prop
][
"
bitmask
"
]
bitmask
=
config_dict
[
board
][
"
property
"
][
prop
][
"
bitmask
"
]
action
=
args
.
action
action
=
args
.
action
value
=
args
.
value
value
=
args
.
value
isMaskContiguous
=
CheckMask
(
bitmask
)
if
not
isMaskContiguous
:
print
(
"
Bit mask %s for property %s at location (%s) is not valid. Check the configuration file
"
%
(
bitmask
,
prop
,
location
,
board
))
exit
()
if
action
==
"
set
"
:
if
action
==
"
set
"
:
if
value
==
None
:
if
value
==
None
:
print
(
"
action
'
set
'
requires the optional argument --value (-v).
"
)
print
(
"
action
'
set
'
requires the optional argument --value (-v).
"
)
...
@@ -130,6 +149,7 @@ if __name__ == '__main__':
...
@@ -130,6 +149,7 @@ if __name__ == '__main__':
print
(
'
Set property %s from location %s on %s: %i
'
%
(
property
,
location
,
board
,
writevalue
.
value
))
print
(
'
Set property %s from location %s on %s: %i
'
%
(
property
,
location
,
board
,
writevalue
.
value
))
else
:
else
:
print
(
'
The value could not be updated. Check the reading permission for property %s in board %s
'
%
(
prop
,
board
))
print
(
'
The value could not be updated. Check the reading permission for property %s in board %s
'
%
(
prop
,
board
))
exit
()
elif
action
==
"
get
"
:
elif
action
==
"
get
"
:
readvalue
=
ReadProperty
(
device
,
location
,
bitmask
)
readvalue
=
ReadProperty
(
device
,
location
,
bitmask
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment