Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » paho mqtt on wago?(cross compile paho mqtt)
paho mqtt on wago? [message #1753327] Fri, 03 February 2017 21:15 Go to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
My college has installed forte on the wago according to the documentation. This worked.
However, we are also needing mqtt.
Has anybody already cross compiled the paho mqtt for wago and could provide the settings?

In the documentation:


1. checkout and build MQTT Paho on Linux or Linux Virtual Machine:

> sudo apt-get install libssl-dev
> git clone https://github.com/eclipse/paho.mqtt.c.git
> cd org.eclipse.paho.mqtt.c.git
> cd <phao src code>
> make
start CMake on Linux or Linux Virtual Machine as you usually do to configure FORTE and follow the next steps:

2.
check FORTE_COM_PHAOMQTT in CMake
set FORTE_COM_PHAOMQTT folder in CMake
configure CMake until nothing is marked red afterwards generate with CMake.
build forte

1. would be compiled native while 2. is cross compiled. Therefore there is an error message at linking them together.

Re: paho mqtt on wago? [message #1753363 is a reply to message #1753327] Sat, 04 February 2017 18:28 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Hi,

you would need to also cross compile mqtt. For a first test you can do this without ssl support. As Wago uses the ptxdist envrionment for building you would need to make your own ptx dist package for mqtt. This would be similar to what we did for FORTE. Maybe the FORTE ptxdist files can even serve you as starting point.

Alois
Re: paho mqtt on wago? [message #1753395 is a reply to message #1753363] Sun, 05 February 2017 19:13 Go to previous messageGo to next message
Herwig Eichler is currently offline Herwig EichlerFriend
Messages: 18
Registered: February 2016
Junior Member
Hi,
I'm not familiar with the Wago ptxdist environment, but I crosscompiled Eclipse Paho MQTT successfully for a Raspberry Pi and used it together with FORTE. First i tried to get the Paho sources from the Repository given on the Eclipse Paho MQTT Website and in the 4DIAC documentation, but that did not work for me. I had to clone the sources from https://github.com/eclipse/paho.mqtt.c.git. If you are not using any special settings, mqtt is compiled and linked with SSL support and you might get a linker error if the openssl includes and libraries are not present on your system.
I also attached a little PDF showing the steps I did to get MQTT up and running, there might be better ways to do it, but it worked for me Wink

Herwig
Re: paho mqtt on wago? [message #1753396 is a reply to message #1753363] Sun, 05 February 2017 19:14 Go to previous messageGo to next message
Herwig Eichler is currently offline Herwig EichlerFriend
Messages: 18
Registered: February 2016
Junior Member
Hi,
I'm not familiar with the Wago ptxdist environment, but I crosscompiled Eclipse Paho MQTT successfully for a Raspberry Pi and used it together with FORTE. First i tried to get the Paho sources from the Repository given on the Eclipse Paho MQTT Website and in the 4DIAC documentation, but that did not work for me. I had to clone the sources from https://github.com/eclipse/paho.mqtt.c.git. If you are not using any special settings, mqtt is compiled and linked with SSL support and you might get a linker error if the openssl includes and libraries are not present on your system.
I also attached a little PDF showing the steps I did to get MQTT up and running, there might be better ways to do it, but it worked for me Wink

Herwig

[Updated on: Sun, 05 February 2017 19:15]

Report message to a moderator

Re: paho mqtt on wago? [message #1753399 is a reply to message #1753396] Sun, 05 February 2017 20:31 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Hi,

you are right per default Paho requires ssl support. But when I compiled Paho for the Bosch Rexroth PLC I found out you can dissable it in Paho's cmake option.

Alois

P.S.: I think the 4diac docs have now also the correct repository to clone.
Re: paho mqtt on wago? [message #1753896 is a reply to message #1753396] Sat, 11 February 2017 23:04 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
Hello,

my collegue could cross-compile paho for wago accordig to the solution provided here (Eichler). On Monday we will try if it works....

Thank you.
Re: paho mqtt on wago? [message #1754446 is a reply to message #1753896] Fri, 17 February 2017 21:19 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
In the meantime we cross compiled it, but it does not work.

Publish1/Subscribe1 say "invalid id" or "terminated", which also is displayed if we write any trash into "ID" of the PUBLISH1 FB. Publish and subscribe programs supplied as Paho examples work on the wago. Starting forte, there is no error.

The connect-function of the paho mqtt layer is never called.
Unfortunately there are many possibilities for making errors but forte compiles and links and there is no helpful errormessage and the logfile is empty.

Here some errors which occured:
- in CMakeList of paho, "mqtt" is set "OFF" by default, which we did not recognise. There is no error message, forte is linked, the project is deployed
- Accidentally we linked the i386 version of the paho libs. There is an error in the output of the ptxdist logfile, but the forte binary was produced. There was no error after deploy.
- the paho directory in the setting for forte was wrong once but forte was linked.
- the mqtt computer has 2 ip addresses, if you use both, paho is not working




Re: paho mqtt on wago? [message #1754447 is a reply to message #1754446] Fri, 17 February 2017 21:20 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
On my computer w/o cross compiler I found in the generated bin directory the code presented below.
The constructor of MQTTComLayer was not called on the forte for wago.
But it was compiled. And paho libs was linked (2 of them, withoud ssl).
I cannot access the computer with the ptxdist cross compiler now, but we can look on Monday, if this code was generated there also.

The CMakeList of the forte paho was adjusted:
forte_add_network_layer(PAHOMQTT OFF "mqtt" MQTTComLayer MQTTComLayer "Enable Paho MQTT Com Layer")
was changed to "ON"

forte_add_link_library( paho-mqtt3a.so paho-mqtt3as.so paho-mqtt3c.so paho-mqtt3cs.so)

was changed:

forte_add_link_library( paho-mqtt3a.so paho-mqtt3c.so)



Here the above mentioned source code:


CComLayer* CComLayersManager::createCommunicationLayer(char *pa_acLayerIdentifier, CComLayer* pa_poUpperLayer, CCommFB * pa_poComFB){
CComLayer* m_poNewLayer = 0;
if(false){}
else if(0 == strcmp("fbdk", pa_acLayerIdentifier)){
m_poNewLayer = new CFBDKASN1ComLayer(pa_poUpperLayer, pa_poComFB);
}

else if(0 == strcmp("ip", pa_acLayerIdentifier)){
m_poNewLayer = new CIPComLayer(pa_poUpperLayer, pa_poComFB);
}

else if(0 == strcmp("loc", pa_acLayerIdentifier)){
m_poNewLayer = new CLocalComLayer(pa_poUpperLayer, pa_poComFB);
}

else if(0 == strcmp("raw", pa_acLayerIdentifier)){
m_poNewLayer = new CRawDataComLayer(pa_poUpperLayer, pa_poComFB);
}

else if(0 == strcmp("json", pa_acLayerIdentifier)){
m_poNewLayer = new CJsonComLayer(pa_poUpperLayer, pa_poComFB);
}

else if(0 == strcmp("mqtt", pa_acLayerIdentifier)){
m_poNewLayer = new MQTTComLayer(pa_poUpperLayer, pa_poComFB);
}


return m_poNewLayer;
}

[Updated on: Fri, 17 February 2017 21:41]

Report message to a moderator

Re: paho mqtt on wago? [message #1754486 is a reply to message #1754447] Sat, 18 February 2017 16:27 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

In order to turn on MQTT you need to explicitly set the CMAKE option FORTE_COM_PAHOMQTT to ON. Only when this option is ON the communication layer will be added to forte. This is true for any comunication layer (e.g., also the JSon layer you proposed).

This can be don either by adjusting the setup_posix.sh, checking the option in the cmake gui or by editing the CMakeCache.txt in your build directory. For Wago you should adjust the FORTE_WAGO_CONF_OPT option of the forte_wago.make of the ptx build system. Please don't change the CMakeList.txt in the mqtt_paho directory.
Re: paho mqtt on wago? [message #1754539 is a reply to message #1754486] Sun, 19 February 2017 22:28 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
> In order to turn on MQTT you need to explicitly set the CMAKE option FORTE_COM_PAHOMQTT to ON. Only when this option is ON the communication layer will be added to forte. This is true for any comunication layer (e.g., also the JSon layer you proposed).

This was already switched on from the beginning.
The change of CMakeList was made at the latest try only.
I guess, without FORTE_COM_PAHOMQTT setting to on, the paho libs would not have been linked to forte.

[Updated on: Sun, 19 February 2017 22:33]

Report message to a moderator

Re: paho mqtt on wago? [message #1754591 is a reply to message #1754539] Mon, 20 February 2017 15:26 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
We had some problems setting up a valid project for testing MQTT, for example if you use the raw layer (raw[].mqtt[...]), the connnection is not opened if the variable which shoud be published is not a string.
But finally, we seen in the debug messages which we have built in, that paho is linked and the functions of this library are also called.
Unfortunately FORTE crashes with Segmentation fault (on the Waog). On my local Linux it works as expected.
I think that there is a bug somewhere, therefore I bugzilla....
Re: paho mqtt on wago? [message #1754608 is a reply to message #1754591] Mon, 20 February 2017 21:18 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

This is a very nasty situation. I never experienced it that it is so hard to get mqtt running on a platform. Espcially as Wago PFC200 is Linux based. We even got it running on vxWorks. There the main issue was to get it compiling. But when we had the lib it worked. I hope we can soon sort it out what is the cause here as well.
Re: paho mqtt on wago? [message #1754869 is a reply to message #1754608] Thu, 23 February 2017 11:03 Go to previous messageGo to next message
Ernst Murnleitner is currently offline Ernst MurnleitnerFriend
Messages: 19
Registered: December 2016
Junior Member
If we exchange the 2 cross compiled paho libs (without ssl) by libs, which were compiled directly on a rasperry pi 2, it works.

Wago PFC200 and the newer Rasperry Pi seem to be binary compatible.
Re: paho mqtt on wago? [message #1754915 is a reply to message #1754869] Thu, 23 February 2017 22:34 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

This is really strange that the ptxdist build is producing a different result. Would be interesting to find out the cause. But good that you have some workaround for you.

Both are arm processors with linux so the binary compatibility seams reasonable.
Previous Topic:FORTE: Bugs in CLocalComLayer
Next Topic:Bug: LINT_TO_TIME, ULINT_TO_TIME, Signed Data Down Counters
Goto Forum:
  


Current Time: Thu Mar 28 21:40:41 GMT 2024

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

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

Back to the top