Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Write Byte Array

More
07 Oct 2020 06:48 #8983 by support
Replied by support on topic Write Byte Array
From the client side, there is no way to tell whether this server behavior is correct or not. It may even be their intent.

The choice between accepting or rejecting the Write with timestamps, even differently on different nodes, is fully in the responsibility of the server, and either way the server does it (for nodes where the spec does not prescribe it somehow), it is OPC UA compliant.

Best regards
The following user(s) said Thank You: phil56

Please Log in or Create an account to join the conversation.

  • phil56
  • Topic Author
  • Visitor
  • Visitor
07 Oct 2020 06:19 #8982 by phil56
Replied by phil56 on topic Write Byte Array
Hello and thank you for your explanations.

Indeed if I use the "Write" method without "timestamp" update, the modification works.
However, if I use the "Write" method to update scalar variables (bool, integer...) with timestamp modification, it works, hence my questioning.
A server bug?

Best regards
Phil

Please Log in or Create an account to join the conversation.

More
06 Oct 2020 15:20 #8980 by support
Replied by support on topic Write Byte Array
Yes, but AFAIK, UaExpert allows you to enter and write value only - that is the equivalent of our WriteValue method. And, as you wrote, WriteValue works OK.

What your other ("Write") example is doing is that it attempts to write the data value AND a timestamp. Not all servers or nodes support that. And the error is telling you that.

Or are you saying that you are somehow able to write data value AND a timestamp with UaExpert? If so, please educate me on how this can be done.

Best regards

Please Log in or Create an account to join the conversation.

  • phil56
  • Topic Author
  • Visitor
  • Visitor
06 Oct 2020 15:12 #8979 by phil56
Replied by phil56 on topic Write Byte Array

support wrote: How do you know that the node you are writing is actually writeable? Have you tried it with some other OPC UA client?
Thank you


For me the node is writable because the WriteWalue method works and if I try another OPC UA client (UAExpert) I can Update the variable.

Please Log in or Create an account to join the conversation.

More
06 Oct 2020 14:39 #8977 by support
Replied by support on topic Write Byte Array
Hello,

the error originated in the server. How do you know that the node you are writing is actually writeable? Have you tried it with some other OPC UA client?

Thank you
The following user(s) said Thank You: phil56

Please Log in or Create an account to join the conversation.

  • phil56
  • Topic Author
  • Visitor
  • Visitor
06 Oct 2020 14:35 #8976 by phil56
Write Byte Array was created by phil56
Hello OPC-Labs team,

In my PLC I have an array of bytes variable, I can read them with the "Read" method but if I want to write bytes into it with the "Write" method, an exception is thrown:
OpcLabs.EasyOpc.UA.OperationModel.UAException: An OPC-UA operation failure with error ID 'Opc.UA.ServiceResult=0x80730000' occurred, originating from 'OpcLabs.EasyOpcUA' and with depth of 1. The inner OPC-UA service exception with service result 'BadWriteNotSupported' contains details about the problem. ---> OpcLabs.EasyOpc.UA.UAServiceException: OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadWriteNotSupported). Details follow.
---- SERVICE RESULT ----
Status Code: {BadWriteNotSupported} = 0x80730000 (2155020288)
 
+ A list of parts provided (or not provided) to the Write operation follows. Value: yes, index range: no, source timestamp: yes, server timestamp: no.
+ The client method called was 'WriteMultiple'.
   --- Fin de la trace de la pile d'exception interne ---
   à OpcLabs.EasyOpc.UA.IEasyUAClientExtension.Write(IEasyUAClient client, UAWriteArguments writeArguments)
   à OpcLabs.EasyOpc.UA.IEasyUAClientExtension.Write(IEasyUAClient client, UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor, UAAttributeData attributeData, Type valueType)
   à OpcLabs.EasyOpc.UA.IEasyUAClientExtension.Write(IEasyUAClient client, UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor, UAAttributeData attributeData)
   à TestOpcUA.Program.Test2() dans D:\vcpp\TestOpcUA47\TestOpcUA\Program.cs:ligne 78
   à TestOpcUA.Program.Main(String[] args) dans D:\vcpp\TestOpcUA47\TestOpcUA\Program.cs:ligne 98

If I use the "WriteValue" method, I can write the bytes without exception.
Where is my mistake?

Sample code with Write method :
            Init();
 
            var client = new EasyUAClient();
            var endPointDescription = new UAEndpointDescriptor("opc.tcp://10.145.14.31:48050");
 
            UAAttributeData attributeData = client.Read(endPointDescription, "ns=7;s=MAIN.barrayV");
 
            object ret = null;
 
            //read ok
            if (attributeData.HasGoodStatus == true)
            {
                ret = attributeData.Value;
 
                var bytes = ret as Byte[];
                for (int i = 0; i < bytes?.Length; i++)
                {
                    bytes[i] = (byte)(1 - bytes[i]);
                }
 
 
                UAAttributeData writeValue = new UAAttributeData(bytes, UASeverity.GoodOrSuccess, DateTime.UtcNow);
                client.Write(endPointDescription, "ns=7;s=MAIN.barrayV", writeValue);
 
            }

Sample code with WriteValue method :
            Init();
 
            var client = new EasyUAClient();
            var endPointDescription = new UAEndpointDescriptor("opc.tcp://10.145.14.31:48050");
 
            UAAttributeData attributeData = client.Read(endPointDescription, "ns=7;s=MAIN.barrayV");
 
            object ret = null;
 
            //read ok
            if (attributeData.HasGoodStatus == true)
            {
                ret = attributeData.Value;
 
                var bytes = ret as Byte[];
                for (int i = 0; i < bytes?.Length; i++)
                {
                    bytes[i] = (byte)(1 - bytes[i]);
                }
 
                client.WriteValue(endPointDescription, "ns=7;s=MAIN.barrayV", bytes);
            }

QuickOPC-UA version 2020.2

best regards
Phil

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.065 seconds