Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sdk:scripts:opcua-write [2015/07/07 08:58] (current)
moll created
Line 1: Line 1:
 +====== SDK Script opcua-write.are ======
 +<code c opcua-write.are>​
 +
 +/* DESC: This script will write a new Value to a Node at a OPC-UA-Server.
 + * Copyright (C) 2012 NetModule AG
 + */
 +
 +void usage () {
 +    printf("​usage:​ opcua-write.are <​opcuaserver>​ <​nodeIndex>​ <​nodeId>​ <​newValue>​\n"​);​
 +    exit(1);
 +}
 +
 +if (argc != 5) {
 +    usage();
 +}
 +
 +opcuaserver = argv[1];
 +nodeIndex = (int) argv[2];
 +nodeId = (int) argv[3];
 +newValue = (int) argv[4];
 +
 +client_0 = nb_opcua_connect(opcuaserver);​
 +if(client_0 >= 0) {
 + ret = nb_opcua_write(client_0,​ nodeIndex, nodeId, newValue);
 + if(ret < 0) {
 + printf("​could not change value of Node Index: %d, Id: %d \n",​nodeIndex,​ nodeId);
 + } else {
 + printf("​succesfully connected and changed to value to %d\n", ret);
 + }
 + nb_opcua_disconnect(client_0);​
 +} else {
 + printf("​could not connect to server %s\n", opcuaserver);​
 +}
 +
 +exit(0);
 +
 +</​code>​