Writing a simple UaProperty value fails

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

Moderator: uasdkcpp

Post Reply
falko.wiese
Hero Member
Hero Member
Posts: 30
Joined: 04 Oct 2012, 17:56

Writing a simple UaProperty value fails

Post by falko.wiese »

Hi guys,
I have a confusing error. I'm trying to write a simple UaProperty on a UaServer hosted in a Schneider Electric PLC.

When I use the C++ SDK with anonymous permissions, the action succeeds with diagnostic code OpcUaBadUserPermissionDenied and the value was not written - the action fails. With user/password permissions, the action succeeds with diagnostic code 0 and the value was not written - the action also fails.

When I use the UaExpert, the value is written - the action succeeds.

Code: Select all

...
            UaStatusCodeArray results;
            UaDiagnosticInfos diagnostic_infos;
            ServiceSettings service_settings;
            service_settings.callTimeout = 30000; // 30 seconds timeout

            // Initialize IN parameter nodesToWrite
            UaWriteValues nodes_to_write;
            nodes_to_write.create(1);
            
            ua_node->id.copyTo(&nodes_to_write[0].NodeId);
            nodes_to_write[0].AttributeId = OpcUa_Attributes_Value;
            ua_value.copyTo(&nodes_to_write[0].Value.Value);

            UaStatus status;
...
                            // Call Write service
                            status = session->write(service_settings, nodes_to_write, results, diagnostic_infos);

                            if (status.isGood())
                            {
                                logging_handler::debug(QString("Write operation completed for node %1").arg(ua_node->id_string()));
                                return true;
                            }

                            print_error_diagnostics();
                            return false;
...
Perhaps one final point to mention. I can easily write to other UA server implementations with this code, except for a Schneider Electric UA server implementation. What am I doing wrong?

Thanks for your help,
Falko Wiese.

falko.wiese
Hero Member
Hero Member
Posts: 30
Joined: 04 Oct 2012, 17:56

Re: Writing a simple UaProperty value fails

Post by falko.wiese »

Solved it myself. My mistake was a wrong data type conversion. The value type on server side is:

Code: Select all

short
but I tried with every other type other than the correct one.

falko.wiese
Hero Member
Hero Member
Posts: 30
Joined: 04 Oct 2012, 17:56

Re: Writing a simple UaProperty value fails

Post by falko.wiese »

Cannot remove duplicate messages. :-)

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

Re: Writing a simple UaProperty value fails

Post by Support Team »

Hi,

still unclear why it worked on other servers, but not this one.
But anyways, good that you solved it.
Best regards
Unified Automation Support Team

falko.wiese
Hero Member
Hero Member
Posts: 30
Joined: 04 Oct 2012, 17:56

Re: Writing a simple UaProperty value fails

Post by falko.wiese »

We integrate foreign machines into our systems. The other vendors that satisfy our Foreign Machine API use the base data type Int32 for this particular UA property. This vendor uses the Int16 data type. Our dynamic conversion mechanism reads the data types from a foreign machine and converts the value from UA to Qt and vice versa. So the simple problem here was that our converter did not take the Int16 data type into account.

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

Re: Writing a simple UaProperty value fails

Post by Support Team »

Hi,

yes, that would be an explanation why the writing failed to this one node. However, "PermissionDenied" and the user/pwd has implied some different problem, or at least pointed in the wrong direction. Some InvalidArg or TypeMismatch error would have been more helpful.

In any case, good that you have found it.
Best regards
Unified Automation Support Team

Post Reply