Page 1 of 1
Enabling MQTT write: works, but values do not stick
Posted: 24 Feb 2022, 10:38
by kjkoster
Dear All,
I enabled MQTT write in the revpipyload configuration. Publishing a value of 1024 to /revpi000/set/PwmDutycycle_1 causes the PWM output to go to 1024 for one cycle only, then it falls back to 0.
I checked the logs: no errors.
I checked that no other processes are active on /dev/PiControl0 and there were none.
So writing works in principle, the value just gets reset to 0 in the next cycle. How can I troubleshoot this further, please?
Kees Jan
Re: Enabling MQTT write: works, but values do not stick
Posted: 26 Feb 2022, 09:53
by kjkoster
Dear All,
I dug a little deeper into this and found that the MQTT server creates its own instance of `RevPiModIO()`. That got me thinking that perhaps these instances might be overwriting one another's IO output list.
Does anyone have a working example? I'd love to learn what I am doing wrong. Anyone who has MQTT writing working on one of their devices?
Kees Jan
Re: Enabling MQTT write: works, but values do not stick
Posted: 27 Feb 2022, 08:26
by kjkoster
Dear All,
After reading the code for `revpypiload` I traced the problem to
https://github.com/naruxde/revpipyload/ ... ipyload.py. The issue is that it instantiates both an MQTT server and a something called the `procimgserver`. My theory is that if you enable MQTT writing (like I have) these both want to write the I/O ports.
Can I safely disable the `procimgserver`?
Kees Jan
PS. I created an issue report on Github too:
https://github.com/naruxde/revpipyload/issues/6
Re: Enabling MQTT write: works, but values do not stick
Posted: 27 Feb 2022, 15:48
by nicolaiB
Hi Kees Jan,
welcome to our forum and thanks for your detailed problem description! Great to see that you already started to investigate what the problem might be.
The procimgsever is used for controlling the IOs via XMLRPC from another PC. It can be disabled if you don't need this functionality.
Nicolai
Re: Enabling MQTT write: works, but values do not stick
Posted: 27 Feb 2022, 17:26
by kjkoster
Dear Nicolai,
Thank you for the welcome. Happy to make detailed reports, of course. I do need this fixed.
I did some more troubleshooting today and I got things to work, but I still need help understanding the logic of the way the configuration works.
But first, the good news: when I enable both `send_on_event` and `write_outputs` in `/etc/revpipyload/revpipyload.conf`, writing values via MQTT works. Glad to find a combination of settings that makes this work.
That still leaves me confused about the logic of the configuration. Below is the original code. It seems that `autorefresh` is enabled in the case of `send_on_event` being set.
Code: Select all
self._rpi = revpimodio2.RevPiModIO(
autorefresh=self._send_events,
monitoring=not self._write_outputs,
configrsc=proginit.pargs.configrsc,
procimg=proginit.pargs.procimg,
replace_io_file=self._replace_ios,
shared_procimg=True,
)
I changed that to the code below, where `autorefresh` gets enabled when either `send_on_event` or `write_outputs` have been set. This seems to work.
Code: Select all
self._rpi = revpimodio2.RevPiModIO(
autorefresh=self._send_events or self._write_outputs,
monitoring=not self._write_outputs,
configrsc=proginit.pargs.configrsc,
procimg=proginit.pargs.procimg,
replace_io_file=self._replace_ios,
shared_procimg=True,
)
I added this fix to the issue on Github. Hope that the author picks this up and reviews my suggested code change.
Re: Enabling MQTT write: works, but values do not stick
Posted: 05 Apr 2022, 19:40
by kjkoster
Dear All,
For those following along, there is an official fix on a separate branch on Github
https://github.com/naruxde/revpipyload/compare/develop Next step would be for someone to roll this into a release version.
Kees Jan
Re: Enabling MQTT write: works, but values do not stick
Posted: 26 Apr 2022, 22:37
by kjkoster
Dear All,
I just noticed that the new release for revpipyload has made it into the apt repositories. If you have a problem similar to mine, you can now solve it by running 'sudo apt update' followed by 'sudo apt full-upgrade'.
Thanks to all involved with the fixes.
Kees Jan