Skip to content

Commit 317595e

Browse files
ondras12345andypugh
authored andcommitted
Add workaround for long keys= in mqtt-publisher
This fixes #3084
1 parent adfc62f commit 317595e

2 files changed

Lines changed: 31 additions & 19 deletions

File tree

docs/src/man/man1/mqtt-publisher.1.adoc

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ debian this is available from the `python3-paho-mqtt` package.
3737

3838
The name of HAL pins, signals and other values to publish using
3939
MQTT. The names are also used as the JSON keys in the MQTT
40-
message published with the broker.
40+
message published with the broker. If multiple "keys=" options
41+
are specified, the lists are merged.
4142

4243
*--dryrun*::
4344

@@ -94,22 +95,33 @@ The loop reading HAL values and publishing MQTT messages.
9495
Any set of HAL pins and signals can be published. This setup might be
9596
a useful starting point:
9697

97-
loadusr -W mqtt-publisher [MQTT]DRYRUN --mqtt-broker=[MQTT]BROKER
98-
--mqtt-user=[MQTT]USERNAME --mqtt-password=[MQTT]PASSWORD
99-
keys=halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,
100-
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,
101-
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,
102-
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,
103-
halui.axis.z.pos-feedback,halui.estop.is-activated,
104-
halui.joint.0.is-homed,halui.joint.1.is-homed,halui.joint.2.is-homed,
105-
halui.joint.3.is-homed,halui.joint.4.is-homed,halui.joint.5.is-homed,
106-
halui.joint.6.is-homed,halui.joint.7.is-homed,halui.joint.8.is-homed,
107-
halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
108-
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
109-
halui.program.is-running'
110-
111-
Note, the list of keys can not include space after comma. The lines
112-
are only broken here to avoid too long lines in the documentation.
98+
----
99+
loadusr -W mqtt-publisher \
100+
[MQTT]DRYRUN \
101+
--mqtt-broker=[MQTT]BROKER
102+
--mqtt-user=[MQTT]USERNAME \
103+
--mqtt-password=[MQTT]PASSWORD \
104+
keys=halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,\
105+
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,\
106+
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,\
107+
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,\
108+
halui.axis.z.pos-feedback \
109+
keys=halui.estop.is-activated, halui.joint.0.is-homed,\
110+
halui.joint.1.is-homed,halui.joint.2.is-homed,halui.joint.3.is-homed,\
111+
halui.joint.4.is-homed,halui.joint.5.is-homed,halui.joint.6.is-homed,\
112+
halui.joint.7.is-homed,halui.joint.8.is-homed \
113+
keys=halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
114+
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
115+
halui.program.is-running
116+
----
117+
118+
Note: It is recommended to use the line continuation character "\" as
119+
shown here to improve readability. But note that spaces must be left in
120+
to delimit options, and must not be included (including at the beginning
121+
of a line) inside a single option.
122+
123+
HAL limits a single option/token (for example "keys=") to 255 characters.
124+
To work around this issue use multiple "keys=" entries as shown.
113125

114126
== SEE ALSO
115127

src/hal/user_comps/mqtt-publisher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def usage():
116116
@staticmethod
117117
def main():
118118
from optparse import Option, OptionParser
119-
keys={}
119+
keys=[]
120120
options = [
121121
Option( '--dryrun', dest='dryrun', action='store_true',
122122
help='Dryrun, only collect HAL pin values, do not send them to MQTT.'),
@@ -147,7 +147,7 @@ def main():
147147

148148
for extra in args:
149149
if 0 == extra.find('keys='):
150-
keys = extra.split('=')[1].split(',')
150+
keys.extend(extra.split('=')[1].split(','))
151151

152152
h = LinuxCNC2MQTT(opts.mqttbroker, opts.mqttport, opts.mqttprefix,
153153
opts.mqttuser, opts.mqttpassword, dryrun=opts.dryrun)

0 commit comments

Comments
 (0)