-1

Hiii, some body know how i can write Uint16Array in kepserver i got some error:

ConstantStatusCode {
_value: 2147483648,
_description: 'The value is bad but no specific reason is known.',
_name: 'Bad' } ]

i'm try this:

var valor = new Uint16Array([ 2, 23, 23, 12, 24, 3, 25, 3, 26, 3, 27, 3, 28, 1, 43690, 1, 1261, 0, 0, 0, 0, 0, 0, 0, 65535, 11 ])

nodeToWrite[0] = {
nodeId: resolveNodeId("ns=2;s=" + endereco[0].ADDRESS),
attributeId: opcua.AttributeIds.Value,

value: /new DataValue(/{ value: {/ Variant /
dataType: 5,
arrayType: 1,
value: valor,
}
}
}

1 Answers1

0
const {AttributeIds, OPCUAClient, DataType, VariantArrayType} = require("node-opcua");

const endpointUrl = "opc.tcp://localhost:48010";
(async () => {

    const client = OPCUAClient.create({ endpoint_must_exist: false});

    await client.withSessionAsync(endpointUrl, async (session) => { 

        const arrayOfvalues = new Uint16Array([ 2, 23, 23, 12, 24, 3, 25, 3, 26, 3, 27, 3, 28, 1, 43690, 1, 1261, 0, 0, 0, 0, 0, 0, 0, 65535, 11 ]);
        const nodeToWrite = {
            nodeId: "ns=2;s=Demo.Static.Arrays.UInt16",
            attributeId: AttributeIds.Value,
            value: { 
                value: {
                    dataType: DataType.UInt16,
                    arrayType: VariantArrayType.Array,
                    value: arrayOfvalues,
                }
            }
        }
        const statusCode = await session.write(nodeToWrite);        
        console.log("write statusCode = ",statusCode.toString());
    });
})();

enter image description here

As demonstrated above, writing a Array of Uint16 is ok when addressing node ns=2;s=Demo.Static.Arrays.UInt16 of UAServerCPP from Unified Automation.

I would contact Kepware for support.

Etienne
  • 16,249
  • 3
  • 26
  • 31