I'm using node-opcua to write a boolean value to set a reset tag. Here's my code:
var nodesToWrite = new Array();
nodesToWrite.push({
nodeId: 'ns=2;s=Paint.PLC.Reset_Auto_Blocked_Time',
attributeId: opcua.AttributeIds.Value,
indexRange: null,
value: {
value: {
dataType: opcua.DataType.Boolean,
value: true
}
}
});
self.uaSession.write(nodesToWrite, function (err, statusCode, diagnosticInfo) {
if (!err) {
console.log(" write ok");
console.log(statusCode);
console.log(diagnosticInfo);
} else {
console.log(" write err = ", err);
}
})
It doesn't actually call "err" because the console logs this:
[{ [Number: 2155085824
value: 2155085824,
description: 'The value supplied for the attribute is not of the same type as the attribute\'s value.',
name: 'BadTypeMidmatch' }]
[]
However, that is clearly an error and the write is never completed. The tag is set in KEPServer as a boolean and works fine. I'm not sure why it's saying it's a mismatch. Any help?
Just use "Boolean" in value.value.dataType
Exemple: