Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » MQTT Clarification
MQTT Clarification [message #1764007] Tue, 23 May 2017 21:43 Go to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member
Hello there!

I am Ahmed, I am trying 4-diac for the first time.

I am using FORTE on Raspberry Pi. I want to use the MQTT communication. I installed MQTT Paho and compiled the FORTE on the Pi.

Now from my Windows system, I am running 4diac on it. In a new 4diac application I have created Publisher/Subscriber FBs. And set their IDs to

raw[].mqtt[192.168.1.200:1883, 123, switch/my]


192.168.1.200 is the IP where MQTT Broker is running.
switch/my is the topic.

My question is that, do I have to install MQTT paho on my windows system and recompile FORTE on windows? Or not?

I am not using FORTE on my local machine, so I guess I don't need it right?
Re: MQTT Clarification [message #1764106 is a reply to message #1764007] Wed, 24 May 2017 22:11 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 454
Registered: January 2014
Senior Member
You are right you only need paho for the FORTEs which are using paho. However when compiling such a FORTE you need to enable the MQTT Paho module in FORTE. Which I assume you did.

however I think your ID is not perfectly right. In mqtt you have to specifiy which protocol to use as part of the broker's address. For using tcp it would be tcp://192.168.1.200:1883



Re: MQTT Clarification [message #1764179 is a reply to message #1764106] Fri, 26 May 2017 12:56 Go to previous messageGo to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member


tcp://192.168.1.200:1883


How can I define topic in this address?
Re: MQTT Clarification [message #1764181 is a reply to message #1764179] Fri, 26 May 2017 13:19 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 454
Registered: January 2014
Senior Member
oh sorry I was not very clear in my answer. The whole configuration string for a Publish or Subscribe FB would be:
raw[].mqtt[tcp://192.168.1.200:1883, 123, switch/my]
Re: MQTT Clarification [message #1764190 is a reply to message #1764181] Fri, 26 May 2017 14:14 Go to previous messageGo to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member
Even with that ID, I can not connect.

I have mosquitto running on Pi. FORTE is also running on Pi.

But when I monitor the FORTE App, I see TERMINATED in the status. And the mosquitto logging doesn't show me any log of connection.

  • Attachment: Capture.JPG
    (Size: 47.24KB, Downloaded 58 times)
Re: MQTT Clarification [message #1764191 is a reply to message #1764190] Fri, 26 May 2017 14:41 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 66
Registered: February 2016
Member
For MQTT the data connection of RD_1 in the Subscribe and SD_1 on Publish MUST be connected to a string. In your case you have an INT2INT, meaning tha the data is connected to a integer. Change it to STRING_TO_INT or similar and it should work.
Re: MQTT Clarification [message #1764192 is a reply to message #1764191] Fri, 26 May 2017 14:51 Go to previous messageGo to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member
At the moment I removed all other FBs, just left the Subscriber block, just to see if it can successfully connect to Mosquitto.
And it never does. All it says "TERMINATED"

[Updated on: Fri, 26 May 2017 15:00]

Report message to a moderator

Re: MQTT Clarification [message #1764197 is a reply to message #1764192] Fri, 26 May 2017 15:09 Go to previous messageGo to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member
Update:

For some reason raw[] doesn't work for me. fbdk[ ] works.

Even though in he CMake I have RAW and FBDK both enabled and compiled in the forte.
Re: MQTT Clarification [message #1764273 is a reply to message #1764197] Sat, 27 May 2017 17:35 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 454
Registered: January 2014
Senior Member
As pointed out by Jose. raw requires that the received or sent data is of type STRING. When you are not connected your input or output then it has type any. this is an error condition for the raw layer and you get the terminated when you invoke send or recieve. furthermore raw only allows one input or one output.
Re: MQTT Clarification [message #1766397 is a reply to message #1764273] Wed, 21 June 2017 04:45 Go to previous messageGo to next message
Ahmed Mujtaba Chang is currently offline Ahmed Mujtaba ChangFriend
Messages: 9
Registered: May 2017
Junior Member
Is there a way to change this raw string to boolean?
Re: MQTT Clarification [message #1766399 is a reply to message #1766397] Wed, 21 June 2017 06:22 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 66
Registered: February 2016
Member
try using a F_STRING_TO_BOL after the subscriber
Re: MQTT Clarification [message #1766401 is a reply to message #1766399] Wed, 21 June 2017 06:51 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 454
Registered: January 2014
Senior Member
The problem with MQTT is that it does not define a payload. Therefore in 4diac we decided, for giving you more flexibility, that on top of the mqtt layer you need a second layer which will take inputs of a publish FB and generate an according payload for MQTT or take the MQTT message and parse it on the outputs. If you both sides (i.e., PUBLISH and SUBSCRIBE) are in 4diac than you can exchange the raw with fbdk and connect any data type. Here you can even have more then one in or output. fbdk will encode the data in an asn1 data format as defined in the "IEC 61499 compliance profile for feasibility demonstrations", which is a very efficient encoding format.

If you have other encodings you may want to write your own layer. Please have a look in the FORTE development documentation to get more information on that.
Previous Topic:No Tracing Events in Forte Console
Next Topic:Set up Unit Test project in VS
Goto Forum:
  


Current Time: Mon Feb 19 18:15:23 GMT 2018

Powered by FUDForum. Page generated in 0.02176 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software