Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for long keys= in mqtt-publisher #3098

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions docs/src/man/man1/mqtt-publisher.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ debian this is available from the `python3-paho-mqtt` package.

== OPTIONS

**keys=**__pin1_[,_pin2_,...]_::
The name of HAL pins, signals and other values to publish using MQTT.
The names are also used as the JSON keys in the MQTT message published with the broker.
*keys*=_pin1[,pin2,...]_::

The name of HAL pins, signals and other values to publish using
MQTT. The names are also used as the JSON keys in the MQTT
message published with the broker.

NOTE: HAL lines are truncated to 255 characters. To work around this
limit with long lists of keys, use multiple keys= tokens. The lists
will be merged.

*--dryrun*::
Do not set up MQTT connection, only print message to stdout.
Expand Down Expand Up @@ -84,27 +90,28 @@ The loop reading HAL values and publishing MQTT messages.

== EXAMPLE

Any set of HAL pins and signals can be published.
This setup might be a useful starting point:

----
loadusr -W mqtt-publisher [MQTT]DRYRUN --mqtt-broker=[MQTT]BROKER
--mqtt-user=[MQTT]USERNAME --mqtt-password=[MQTT]PASSWORD
keys=halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,
halui.axis.z.pos-feedback,halui.estop.is-activated,
halui.joint.0.is-homed,halui.joint.1.is-homed,halui.joint.2.is-homed,
halui.joint.3.is-homed,halui.joint.4.is-homed,halui.joint.5.is-homed,
halui.joint.6.is-homed,halui.joint.7.is-homed,halui.joint.8.is-homed,
halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
halui.program.is-running'
----

Note: The list of keys can not include space after comma.
The lines are appear broken only to avoid too long lines in the documentation.
Any set of HAL pins and signals can be published. This setup might be
a useful starting point:

loadusr -W mqtt-publisher [MQTT]DRYRUN --mqtt-broker=[MQTT]BROKER
--mqtt-user=[MQTT]USERNAME --mqtt-password=[MQTT]PASSWORD
keys=halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,
halui.axis.z.pos-feedback keys=halui.estop.is-activated,
halui.joint.0.is-homed,halui.joint.1.is-homed,halui.joint.2.is-homed,
halui.joint.3.is-homed,halui.joint.4.is-homed,halui.joint.5.is-homed,
halui.joint.6.is-homed,halui.joint.7.is-homed,halui.joint.8.is-homed
keys=halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
halui.program.is-running

Note, the list of keys cannot include space after comma. The lines
are only broken here to avoid too long lines in the documentation.

HAL limits option length to 255 characters. To work around this multiple keys=
options can be used if necessary.

== SEE ALSO

Expand Down
4 changes: 2 additions & 2 deletions src/hal/user_comps/mqtt-publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def usage():
@staticmethod
def main():
from optparse import Option, OptionParser
keys={}
keys=[]
options = [
Option( '--dryrun', dest='dryrun', action='store_true',
help='Dryrun, only collect HAL pin values, do not send them to MQTT.'),
Expand Down Expand Up @@ -147,7 +147,7 @@ def main():

for extra in args:
if 0 == extra.find('keys='):
keys = extra.split('=')[1].split(',')
keys.extend(extra.split('=')[1].split(','))

h = LinuxCNC2MQTT(opts.mqttbroker, opts.mqttport, opts.mqttprefix,
opts.mqttuser, opts.mqttpassword, dryrun=opts.dryrun)
Expand Down
Loading