Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ieee802154-radio-eval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
cm-projects
ieee802154-radio-eval
Commits
fba21b2d
Commit
fba21b2d
authored
5 years ago
by
Torben Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Logging of node output implemented, removed unnecessary code
parent
2052d12f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
software/coordinator2.py
+11
-23
11 additions, 23 deletions
software/coordinator2.py
with
11 additions
and
23 deletions
software/coordinator2.py
+
11
−
23
View file @
fba21b2d
...
...
@@ -185,6 +185,7 @@ class PRREvalClient(Thread):
self
.
HUB_DISCOVERY_TOPIC
=
"
hotplug/{}/discovery
"
.
format
(
self
.
server
)
self
.
HUB_DISCOVERY_ANSWER_TOPIC
=
"
hotplug/{}/discovery/answer
"
.
format
(
self
.
server
)
self
.
file_formatter
=
logging
.
Formatter
(
'
%(message)s
'
)
self
.
logger
.
debug
(
"
Init done
"
)
...
...
@@ -214,7 +215,14 @@ class PRREvalClient(Thread):
elif
topic
[
0
]
==
"
hotplug
"
and
len
(
topic
)
==
4
:
unpacked_msg
=
str
(
msg
.
payload
)[
2
:][:
-
1
]
node_id
=
topic
[
2
]
self
.
logger
.
debug
(
"
{}: {}
"
.
format
(
node_id
,
unpacked_msg
))
fh
=
logging
.
FileHandler
(
"
{}.log
"
.
format
(
node_id
))
fh
.
setLevel
(
logging
.
DEBUG
)
fh
.
setFormatter
(
self
.
file_formatter
)
self
.
logger
.
addHandler
(
fh
)
self
.
logger
.
info
(
"
{}
\t
{}: {}
"
.
format
(
time
(),
node_id
,
unpacked_msg
))
self
.
logger
.
removeHandler
(
fh
)
else
:
print
(
"
[on_message] {} {}
"
.
format
(
msg
.
payload
,
msg
.
topic
)
)
...
...
@@ -227,9 +235,6 @@ class PRREvalClient(Thread):
global
eval_round
self
.
logger
.
info
(
"
Hallo
"
)
# for angle in [0,25,50,75,100,125,150,175]:
# self.set_angle(angle)
# sleep(0.5)
for
channel
in
CHANNELS
:
self
.
logger
.
info
(
"
CHANNEL={}
"
.
format
(
channel
)
)
self
.
set_channel
(
channel
)
...
...
@@ -240,7 +245,7 @@ class PRREvalClient(Thread):
sleep
(
0.5
)
for
payload
in
PAYLOADS
:
self
.
logger
.
info
(
"
PAYLOAD={}
"
.
format
(
payload
)
)
self
.
send_all
(
"
payload {}
\n
"
.
format
(
payload
)
)
self
.
send_all
(
"
payload {}
"
.
format
(
payload
)
)
sleep
(
0.5
)
db_lock
.
acquire
()
r
=
Round
(
angle
=-
1
,
channel
=
channel
,
power
=
power
,
payload
=
payload
,
ts
=
time
()
)
...
...
@@ -277,13 +282,6 @@ class PRREvalClient(Thread):
self
.
logger
.
warn
(
"
Unable to stop: not alive
"
)
return
False
def
set_angle
(
self
,
angle
):
self
.
logger
.
debug
(
"
ANGLE={}
"
.
format
(
angle
))
# {'module': ['SerialStepperMotorModule']}
#self.send({'dst': {'id': ['lctc-01-serialsteppermotormodule']}, 'type': 'set_position', 'position': angle})
pass
def
set_channel
(
self
,
channel
):
#self.send_all("ifconfig 3 set state idle\n")
self
.
send_all
(
"
ifconfig 3 set channel {}
"
.
format
(
channel
))
...
...
@@ -293,6 +291,7 @@ class PRREvalClient(Thread):
def
send_all
(
self
,
line
):
for
sender
in
self
.
my_nodes
:
self
.
logger
.
debug
(
"
Sending to node: {}
"
.
format
(
sender
))
self
.
send
(
sender
,
line
)
#self.send({'dst': {'id': self.my_nodes}, 'type': 'serial_tx', 'line': line})
...
...
@@ -301,17 +300,6 @@ class PRREvalClient(Thread):
self
.
client
.
publish
(
tx_topic
,
bytes
(
line
,
'
utf-8
'
),
qos
=
2
)
pass
def
callback_receive
(
self
,
data_dict
):
if
'
type
'
in
data_dict
:
if
data_dict
[
'
type
'
]
==
'
serial_rx
'
:
if
handle_serial_rx
(
data_dict
):
return
True
else
:
self
.
logger
.
debug
(
"
[{}] {}
"
.
format
(
data_dict
[
'
src
'
][
'
id
'
][
0
],
data_dict
[
'
line
'
]
)
)
return
True
self
.
logger
.
debug
(
data_dict
)
if
__name__
==
'
__main__
'
:
coloredlogs
.
install
(
fmt
=
'
%(asctime)s %(name)s %(levelname)s %(message)s
'
,
level
=
0
)
client
=
PRREvalClient
()
...
...
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