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
72342e90
Commit
72342e90
authored
3 years ago
by
Torben Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Changed Hotplug.py - can now make difference between inga_blue and telosb
parent
4d1399a0
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
-1
15 additions, 1 deletion
modules/hotplug.py
with
15 additions
and
1 deletion
modules/hotplug.py
+
15
−
1
View file @
72342e90
...
...
@@ -44,6 +44,7 @@ class DefaultProtocol(LineReader):
#self.transport.send({'dst': {'logging': True}, 'type': 'serial_rx', 'line': line, 'ts': time()})
rx_topic
=
self
.
transport
.
hotplug_module
.
mqtt_topic_prefix
+
self
.
transport
.
serial_number
+
"
/rx
"
self
.
transport
.
hotplug_module
.
logger
.
debug
(
"
Publishing on topic {}
"
.
format
(
rx_topic
))
self
.
transport
.
hotplug_module
.
logger
.
debug
(
"
Received: {}
"
.
format
(
line
))
self
.
transport
.
hotplug_module
.
mqtt_client
.
publish
(
rx_topic
,
bytes
(
line
,
'
utf-8
'
),
qos
=
2
)
...
...
@@ -233,6 +234,7 @@ class Hotplug(Module):
pattern1
=
base_pattern
+
"
*/ttyUSB*
"
path_serial_number
=
base_pattern
+
"
/serial
"
path_manufacturer
=
base_pattern
+
"
/manufacturer
"
path_product
=
base_pattern
+
"
/product
"
# TODO replace glob?
result1
=
glob
.
glob
(
pattern1
)
...
...
@@ -260,14 +262,26 @@ class Hotplug(Module):
with
open
(
path_manufacturer
,
'
r
'
)
as
fh
:
device_manufacturer
=
fh
.
read
().
strip
()
device_product
=
None
if
os
.
path
.
exists
(
path_product
):
with
open
(
path_product
,
'
r
'
)
as
fh
:
device_product
=
fh
.
read
().
strip
()
self
.
logger
.
debug
(
"
Found serial number: {}
"
.
format
(
serial_number
))
self
.
logger
.
debug
(
"
Found serial port name: {}
"
.
format
(
serial_port_name
))
self
.
logger
.
debug
(
"
Found manufacturer: {}
"
.
format
(
device_manufacturer
))
self
.
logger
.
debug
(
"
Found product: {}
"
.
format
(
device_product
))
if
serial_config
[
'
type
'
]
==
'
USB
'
:
if
device_manufacturer
==
"
IBR
"
:
baud
=
19200
print
(
"
Baud is 19200
"
)
else
:
baud
=
9600
if
device_product
==
"
MTM-CM5000MSP
"
:
baud
=
9600
print
(
"
Baud is 9600
"
)
else
:
baud
=
19200
print
(
"
Baud is 19200
"
)
ser
=
serial
.
serial_for_url
(
"
/dev/
"
+
serial_port_name
,
baudrate
=
baud
,
timeout
=
1
)
else
:
ser
=
serial
.
serial_for_url
(
"
/dev/
"
+
serial_port_name
,
baudrate
=
serial_config
[
'
baud
'
],
timeout
=
1
)
...
...
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