Page 1 of 1

RevPiPyLoad not sending MQTT? And some basic questions

Posted: 04 May 2022, 13:47
by GardG
I'm trying to use RevPiPyLoad to send received data from a virtual Modbus Master over MQTT to Node-Red, and also to output DMX from Node-Red using a DMX gateway. So far it's not going very well.

I have followed this tutorial and configured revpipyload.conf as the tutorial prescribes. However, when I try to test using $ mosquitto_sub -t "#" -v I don't see any MQTT activity at all. I have checked the "export" box on all the variables I want to send over MQTT, and I've confirmed using piTest that there is data there, but it doesn't get through.

If I just send some random MQTT data from Node-Red to the local mosquitto broker, I can see that data in the terminal, which indicates that the broker works and mosquitto_sub is receiving.

There are two more things I would've done to troubleshoot, but I honestly can't figure out how …
1) I'd connect a pushbutton to RevPi Connect's onboard input and see if I can get that data through over MQTT – but I don't know where in the process image to find that input, and despite honest attempts to search I just haven't found any information on this
2) I'd try to turn on an onboard LED from Node-Red, but I don't know what MQTT message to send. I've found information on what bits to set using piTest, but from the RevPiPyLoad tutorial it seems it's done differently there. I've tried sending a boolean true to revpi/set/led1, but that's not doing anything.

Just to try something completely different I also enabled Node-RED RevPi Nodes Server, but I get an "unsupported server" error when connecting to localhost:8000.

Any clues?

EDIT: I found the RevPiPyLoad logs, there are a lot of these errors:

Code: Select all

2022-05-04 11:48:26 [ERROR   ] 'Connect' object has no attribute '__evt_wdtoggle'
2022-05-04 11:48:26 [ERROR   ] plc file does not exists /var/lib/revpipyload/program.py
2022-05-04 11:51:23 [ERROR   ] 'Connect' object has no attribute '__evt_wdtoggle'
2022-05-04 11:51:23 [ERROR   ] plc file does not exists /var/lib/revpipyload/program.py
2022-05-04 12:31:20 [ERROR   ] 'Connect' object has no attribute '__evt_wdtoggle'
2022-05-04 12:31:20 [ERROR   ] plc file does not exists /var/lib/revpipyload/program.py
2022-05-04 14:03:51 [ERROR   ] 'Connect' object has no attribute '__evt_wdtoggle'
2022-05-04 14:03:51 [ERROR   ] plc file does not exists /var/lib/revpipyload/program.py

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 04 May 2022, 21:44
by kjkoster
Dear GardG,

From your description, I gather that you have Node-RED <-> MQTT working, but it sounds like revpipyload <-> MQTT is not working. While it pretty much worked out of the box for me, I still had a few gotcha’s that may help you.

For reference, can you please share the [MQTT] section in your /etc/revpipyload/revpipyload.conf? Also, I am on Buster and not Stretch. Not sure that makes a difference.

I ran into a few since-fixed issues that writing values into the Revolution Pi I/O would not work. See https://revolutionpi.com/forum/viewtopic.php?t=3320 and https://revolutionpi.com/forum/viewtopic.php?t=3371 The short version is that you should upgrade to at least version 0.9.7 of revypyload and 2.0.6 of Pictory. You can check your installed versions as shown below:

Code: Select all

$ apt list --installed | egrep '(pictory|revpipyload)'
pictory/buster,now 2.0.6 all [installed]
revpipyload/buster,now 0.9.7-1+revpi10 all [installed]
After upgrading Pictory, don’t forget to re-add the I/O module, do “save as start-config” and finally reset the driver. I made the mistake to skip one of these steps and that cost me some time to find out.

With pictory and revpipyload at these versions, I can use (for example) "revpi<serial>/set/PwmDutycycle_1" to control the PWM dutycycle on one of my I/O ports. The data flows in on "revpi<serial>/io/PwmDutycycle_1”.

Good you already found the right log files. The message "plc file does not exists /var/lib/revpipyload/program.py” is harmless, if a little confusing. The other message I don’t know. Perhaps someone from Kunbus can comment?

If you can post the MQTT section from /etc/revpipyload/revpipyload.conf, perhaps we can work out what is happening.

Kees Jan

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 10 May 2022, 10:08
by kjkoster
Dear GardG,

I stand corrected. You were right that MQTT does not work. In fact, it is the latest release of revpypiload that breaks MQTT completely, so my proposed solution only works to break things.

To get things working again (and until there is a new release of revpipyload) you should downgrade to version 0.9.6

Code: Select all

$ sudo apt install revpipyload=0.9.6-1+revpi10 -V
After downgrading, check the installed version again:

Code: Select all

$ apt list --installed | fgrep 'revpipyload'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

revpipyload/buster,now 0.9.6-1+revpi10 all [installed,upgradable to: 0.9.7-1+revpi10]
This release will send data to the MQTT bus, but will not set the outputs when you write to it. For that, you need to monkey-patch the MQTT server until a proper release is published:

Code: Select all

--- mqttserver.py.orig	2022-05-10 10:01:35.241870607 +0200
+++ mqttserver.py	2022-05-07 14:44:12.768757816 +0200
@@ -333,6 +333,9 @@
                 # Write Value to RevPi
                 try:
                     io.value = value
+                    # Write data without autorefresh
+                    if not self._send_events:
+                        io._parentdevice.writeprocimg()
                 except Exception:
                     proginit.logger.error(
                         "could not write '{0}' to Output '{1}’"
I opened a bug report on the upstream github project. https://github.com/naruxde/revpipyload/issues/9

Apologies for steering you in the wrong direction.

Kees Jan

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 10 May 2022, 10:27
by RevPiModIO
Found the bug, will fix right now!

Sven

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 10 May 2022, 11:12
by RevPiModIO

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 10 May 2022, 11:53
by kjkoster
Dear Sven,

Hmmyeah, that solves the error, but now I get this one:

Code: Select all

2022-04-24 07:53:05 [ERROR   ] can not find io 'core.a2red2' for MQTT
2022-04-24 07:53:05 [ERROR   ] can not find io 'core.a2red3' for MQTT
I have a blinky running via MQTT and 'core.a1green' seems to work.

Kees Jan

Re: RevPiPyLoad not sending MQTT? And some basic questions

Posted: 10 May 2022, 11:58
by kjkoster
Dear Sven,

Ugh, scratch that. This is bad data that I have on the MQTT bus on my test system. It has "retain" set, so it gets to revpipyload. So your quick fix resolves the error and the messages I see were caused by myself.

Kees Jan