logo

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline Stefano Magnoni  
#1 Posted : Friday, January 22, 2016 5:23:59 AM(UTC)
Stefano Magnoni

Rank: Newbie

Joined: 1/22/2016(UTC)
Posts: 1

Hello.

I have installed the library and I am trying to write a simple client.
I have copied the code from the QuickConnect Lesson but as soon as I call the GetEndPoints the application segments.

here the code:
Code:

#include <stdio.h>
#include <stdlib.h>
#include <UAClientHeaders.h>

using namespace std;
using namespace Mtk::Ua::Stack;
using namespace Mtk::Ua::ClientSDK;
using namespace Mtk::General;

int main(void) {
	std::cout << "start" << std::endl;

    //1. Initialize
    //
    // Connection Config - set default connectivity info
    std::shared_ptr<IUaConnectionConfiguration>uaConnectionConfig(IUaConnectionConfiguration::Create());
    uaConnectionConfig->NetworkTimeout() = 10000;
    uaConnectionConfig->Lifetime() = 1000 * 60 * 60; //1 hour
    uaConnectionConfig->AutoConnect() = true; // Set to auto connect
    // Session Config - set default session connection info
    std::shared_ptr<IUaClientSessionConfiguration> uaSessionConfig(IUaClientSessionConfiguration::Create());
    uaSessionConfig->SessionTimeout() = 1000 * 60 * 20; //20 minutes
    uaSessionConfig->ClientApplicationDescription().ApplicationName().Text() = L"My UA Client App";
    uaSessionConfig->ClientApplicationDescription().SetApplicationType(Enums::ApplicationType_Client);
    uaSessionConfig->ClientApplicationDescription().ProductUri() = L"http://HoneywellOpc.com/UA Client Toolkit";
    uaSessionConfig->ClientApplicationDescription().ApplicationUri() = L"http://HoneywellOpc.com/UA Client Toolkit";
    //locals to hold endpoints/info
    std::shared_ptr<Mtk::Ua::Stack::IEndpointDescriptionArray> foundEndpoints;
    foundEndpoints.reset(IEndpointDescriptionArray::Create());
    //Setup Localization
    std::shared_ptr<Mtk::Ua::Stack::IUaStringArray> localeId(Mtk::Ua::Stack::IUaStringArray::Create());
    localeId->Resize(1);
    (*localeId)[0] = L"en";


    //2. Get Endpoints
    // Specifies the UA server's Url
    //std::string serverURL = "opc.tcp://123.456.789.000:51210/UA/SampleServer";
    std::string serverURL = "opc.tcp://TESTMACHINE:4840/";
    Result status(DOMAIN_GENERAL, IResult::Good);
    std::shared_ptr<Mtk::Ua::Stack::IUaStringArray> profileUris(Mtk::Ua::Stack::IUaStringArray::Create());
    if (!IUaConnection::GetEndpoints(serverURL.c_str(), *localeId, *profileUris, *foundEndpoints, status))
    {
        //endpoint errors
        wcout << status.ToString().c_str() << endl;
        return -1;
    }
    if (foundEndpoints->GetLength() == 0)
    {
        wcout << "No endpoints found." << endl;
        return -1;
    }

    std::cout << "end" << std::endl;
}


and following the stack trace:
Code:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5bf3900 in sem_post () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.17-106.el7_2.1.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.13.2-10.el7.x86_64 libcom_err-1.42.9-7.el7.x86_64 libgcc-4.8.5-4.el7.x86_64 libicu-50.1.2-15.el7.x86_64 libselinux-2.2.2-6.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 openssl-libs-1.0.1e-51.el7_2.2.x86_64 pcre-8.32-15.el7.x86_64 xz-libs-5.1.2-12alpha.el7.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) bt
#0  0x00007ffff5bf3900 in sem_post () from /lib64/libpthread.so.0
#1  0x00007ffff6ae221c in OpcUa_P_Semaphore_Post () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#2  0x00007ffff6ae8e87 in OpcUa_P_Timer_Create () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#3  0x00007ffff6a338b3 in OpcUa_Timer_Create () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#4  0x00007ffff6a4d671 in OpcUa_SecureConnection_Create () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#5  0x00007ffff6a35b9c in OpcUa_Channel_BeginConnect () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#6  0x00007ffff6a35e37 in OpcUa_Channel_Connect () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libua.so.1
#7  0x00007ffff70a80e1 in Mtk::Ua::Stack::Channel::Connect(Mtk::General::IResult&) () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libStackWrapper.so.1
#8  0x00007ffff7b48c68 in Mtk::Ua::ClientSDK::UaConnectionPrivate::Connect(Mtk::General::IResult&) () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libClientSdk.so.1
#9  0x00007ffff7b4badd in Mtk::Ua::ClientSDK::UaConnection::Connect(Mtk::General::IResult&) () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libClientSdk.so.1
#10 0x00007ffff7b44cda in Mtk::Ua::ClientSDK::IUaConnection::GetEndpoints(char const*, Mtk::Ua::Stack::IUaStringArray const&, Mtk::Ua::Stack::IUaStringArray const&, unsigned int, Mtk::Ua::Stack::IEndpointDescriptionArray&, Mtk::General::IResult&) () from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libClientSdk.so.1
#11 0x00007ffff7b450d1 in Mtk::Ua::ClientSDK::IUaConnection::GetEndpoints(char const*, Mtk::Ua::Stack::IUaStringArray const&, Mtk::Ua::Stack::IUaStringArray const&, Mtk::Ua::Stack::IEndpointDescriptionArray&, Mtk::General::IResult&) ()
   from /opt/MatrikonOPC-UA-SDK-1.2.0-Linux-x86_64/lib/libClientSdk.so.1
#12 0x0000000000402d76 in main () at matrikonClient.cpp:49
(gdb)


It looks to me that the problem is related with the "status" variable I passed but this is done exactly like in the example. Any Idea what the problem could be?


Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.