node-opc-da
node-opc-da copied to clipboard
Cannot write to OPC variable
Hi.
Can you provide a sample code in order to write varible to OPC Server?
Basically in write() of opcSyncIO.js it passed write.value and write.handle to construct a ComValue, which is wrong. It should pass write.value[0]/write.handle[0] instead. But there is still a glitch in return value, which shows negative value(-1073479674) as below. Look inside write() and _comObj.call(callObject) returns OK. Any idea?
`let types = []; let values = []; types[0] = Types.SHORT; values[0] = 3;
let valueObj = [];
valueObj[0] = { handle: serverHandles, type: types, value: values };
let resultWrite = await opcSyncIO.write(valueObj);
console.log(resultWrite[0].getValue());`
Yes. We found the solution after update node-dcom project. I updated and sent push back to repository to write variables.
Thanks for your advice
Greetings
We've been busy with lots of other projects but we plan to update the libs with the changes as soon as we have the time and we decide how to present the writing function to the user on our Node-RED node. The changes made by @emrebekar in node-dcom
and node-opc-da
are already merged but new releases of npm packages will only happen when we also update node-red-contrib-opc-da
.
A temporary fix would be installing directly from the github repository. If you've found a new bug we missed in the last changes please open a new issue.
Ty for your understanding