getting started lessons

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
diana
Sr. Member
Sr. Member
Posts: 11
Joined: 27 Nov 2012, 08:16

getting started lessons

Post by diana »

Hi all,

I have a problem with lessons in "getting started" folders for server and client implementation under Linux with C++.

Precisely, using the server implemented in lesson 7, and client implemented in lesson 4, the connection and browsing services work fine. Read and Write services do not work and I get the following error message:

Code: Select all

****************************************************************
** Try to call read for configured node ids
** Error: UaSession::read failed [ret=BadNothingToDo] *********


****************************************************************
** Try to call write for configured node ids
** Error: UaSession::write failed [ret=BadNothingToDo] *********

Why does it happen? Any idea?

Thanks in advance,

Diana

diana
Sr. Member
Sr. Member
Posts: 11
Joined: 27 Nov 2012, 08:16

Re:getting started lessons

Post by diana »

Hi Unified Automation team,

In addition to my previous message, is it possible that the problem is related to certification issues? I've just compiled both server and client in lessons 7 and 4 respectively but read and write services do not work. Is there something essential that I'm neglecting?

diana
Sr. Member
Sr. Member
Posts: 11
Joined: 27 Nov 2012, 08:16

Re:getting started lessons

Post by diana »

I've copied the PKI folder found in the server also in the client but the problem persists. I would be very grateful if somebody can help me in solving this problem.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re:getting started lessons

Post by Support Team »

Hello Diana,
if you can connect and browse there is no issue with the certificates.

I just checked the examples and I can reproduce the error you get. There is an issue in the client getting started example.
The read and write calls use global lists of NodeIds. These lists are empty. That's why you see the error BadNothingToDo.

In client lesson 4 go to the read() method.
For playing around with the read and write you can just hard code the NodeIds (Use the UaExpert to get the NodeIds from the server).

Add the following code there (if you use the server from lesson 7):

Code: Select all

    // Initialize IN parameter nodesToRead 
    /*
    count = g_VariableNodeIds.length();
    nodesToRead.create(count);
    for ( i=0; i<count; i++ )
    {
        g_VariableNodeIds[i].copyTo(&nodesToRead[i].NodeId);
        nodesToRead[i].AttributeId = OpcUa_Attributes_Value;
    }
    */

    count = 2;
    nodesToRead.create(2);
    UaNodeId nodeId;
    
    nodeId = UaNodeId("AirConditioner_1.Humidity", 2);
    nodeId.copyTo(&nodesToRead[0].NodeId);
    nodesToRead[0].AttributeId = OpcUa_Attributes_Value;

    nodeId = UaNodeId("AirConditioner_1.Temperature", 2);
    nodeId.copyTo(&nodesToRead[1].NodeId);
    nodesToRead[1].AttributeId = OpcUa_Attributes_Value;
Sorry about the inconvenience. We'll update the example lessons for the next release.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

diana
Sr. Member
Sr. Member
Posts: 11
Joined: 27 Nov 2012, 08:16

Re:getting started lessons

Post by diana »

Many thanks for the reply... I'll keep you posted.

diana
Sr. Member
Sr. Member
Posts: 11
Joined: 27 Nov 2012, 08:16

Re:getting started lessons

Post by diana »

Dear UA Support Team,

The read() now works well but I have some problem with write(). Based on your sample code, I've modified the write() method as follows:

Code: Select all

    count = 2; 
    nodesToWrite.create(2); 
    UaNodeId nodeId; 
     
    nodeId = UaNodeId("AirConditioner_1.Humidity", 2); 
    nodeId.copyTo(&nodesToWrite[0].NodeId); 
    nodesToWrite[0].AttributeId = OpcUa_Attributes_Value; 
    tempValue.setDouble(13.0);
    tempValue.copyTo(&nodesToWrite[0].Value.Value);
    
    nodeId = UaNodeId("AirConditioner_1.Temperature", 2); 
    nodeId.copyTo(&nodesToWrite[1].NodeId); 
    nodesToWrite[1].AttributeId = OpcUa_Attributes_Value;
    tempValue.setDouble(10.0);
    tempValue.copyTo(&nodesToWrite[1].Value.Value);
Unfortunately, when I run the client I get the following error message:

Code: Select all

** Try to call write for configured node ids
** UaSession::write result **************************************
** Variable AirConditioner_1.Humidity failed!
** Variable AirConditioner_1.Temperature failed!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re:getting started lessons

Post by Support Team »

The 2 variables you are using are not writable. You can see that by locking at the UserAccessLevel attribute e.g. using the UaExpert.

You can use the HumiditySetpoint or TemperatureSetPoint for writing.

Hint: Adding this piece of code will show you the individual errors you get while writing:

Code: Select all

...
if ( OpcUa_IsGood(results[i]) )
{
    printf("** Variable %s succeeded!n", node.toString().toUtf8());
}
else
{
    printf("** Variable %s failed!n", node.toString().toUtf8());
    printf("** ErrorCode: %sn", UaStatusCode(results[i]).toString().toUtf8());
}
...
Best regards
Unified Automation Support Team

Post Reply