/* DESC: This script will read the node value at a OPC-UA server. * Copyright (C) 2015 NetModule AG, Switzerland */ void usage () { printf("usage: opcua-read.are <server> <port> <node-index> <node-id>\n"); exit(1); } if (argc != 4) { 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) */ 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); } value = nb_opcua_read(client, nindex, nid); if (is_void(value)) { printf("unable to read value of node %d:%d", nindex, nid); } else { dump(value); } nb_opcua_disconnect(client); exit(0);