node-opc-da icon indicating copy to clipboard operation
node-opc-da copied to clipboard

Cannot write to OPC variable

Open emrebekar opened this issue 4 years ago • 3 comments

Hi.

Can you provide a sample code in order to write varible to OPC Server?

emrebekar avatar May 02 '20 06:05 emrebekar

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());`

duduyoyo avatar Oct 09 '20 03:10 duduyoyo

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

emrebekar avatar Oct 09 '20 05:10 emrebekar

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

steuck13 avatar Oct 14 '20 13:10 steuck13