Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
testbed-software
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
Robert Hartung
testbed-software
Commits
193fdf1e
Commit
193fdf1e
authored
5 years ago
by
Torben Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Started implementing the sending of messaged towards the node via mqtt
parent
4d73703e
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
modules/hotplug.py
+15
-0
15 additions, 0 deletions
modules/hotplug.py
with
15 additions
and
0 deletions
modules/hotplug.py
+
15
−
0
View file @
193fdf1e
...
...
@@ -56,6 +56,11 @@ class DefaultThread(ReaderThread):
self
.
usb_device
=
usb_device
self
.
serial_number
=
serial_number
self
.
logger
=
Logger
(
__name__
+
'
.
'
+
self
.
__class__
.
__name__
)
tx_topic
=
self
.
hotplug_module
.
mqtt_topic_prefix
+
self
.
serial_number
+
"
/tx
"
self
.
hotplug_module
.
logger
.
debug
(
"
Subscribed to topic {}
"
.
format
(
tx_topic
))
self
.
hotplug_module
.
mqtt_client
.
subscribe
(
tx_topic
,
qos
=
2
)
super
(
DefaultThread
,
self
).
__init__
(
serial
,
protocol
)
def
run
(
self
):
...
...
@@ -116,6 +121,8 @@ class Hotplug(Module):
handle
=
hotplug
.
register_callback
(
events
,
flags
,
0x0403
,
0x6001
,
dev_class
,
self
.
hotplug_callback
,
{
'
baud
'
:
19200
})
self
.
handles
.
append
(
handle
)
self
.
mqtt_client
.
on_message
=
self
.
on_message
return
#TODO
if
hasattr
(
node_config
,
'
serial
'
):
...
...
@@ -135,6 +142,14 @@ class Hotplug(Module):
#product_id = 0x204b
#handle = hotplug.register_callback(events, flags, vendor_id, product_id, dev_class, self.hotplug_callback, user_data)
def
on_message
(
self
,
client
,
userdata
,
msg
):
node_id
=
msg
.
topic
.
split
(
'
/
'
)[
2
]
self
.
logger
.
debug
(
"
Got message for {}
"
.
format
(
node_id
))
self
.
logger
.
debug
(
"
Length of devices: {}
"
.
format
(
len
(
self
.
devices
)))
for
addr
,
node_device
in
self
.
devices
.
items
():
self
.
logger
.
debug
(
"
Checking node_device with serial number {}
"
.
format
(
node_device
.
serial_number
))
if
node_device
.
serial_number
==
node_id
:
self
.
logger
.
debug
(
"
Found device, forwarding message
"
)
#def send(self, send_dict):
# self.callback_send(send_dict)
...
...
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