/* DESC: This script will write a new value to a node at a OPC-UA server. * Copyright (C) 2015 NetModule AG, Switzerland */ void usage () { printf("usage: opcua-write.are \n"); exit(1); } if (argc != 5) { usage(); } server = argv[1]; /* hostname or address */ port = (int) argv[2]; /* TCP port */ nindex = (int) argv[3]; /* node index (e.g. 0) */ nid = (int) argv[4]; /* node id (e.g. 85 = root) */ value = argv[5]; /* new value */ url = sprintf("opc.tcp://%s:%d", server, port); client = nb_opcua_connect(url); if (client < 0) { printf("unable to connect to %s", url); exit(0); } ret = nb_opcua_write(client, nindex, nid, value); if (ret < 0) { printf("unable to write value of node %d:%d", nindex, nid); } else { printf("node %d:%d has been written", nindex, nid); } nb_opcua_disconnect(client); exit(0);