This is an old revision of the document!


SDK Script opcua-read.are

opcua-read.are
/* DESC: This script will read the Value from a Node at a OPC-UA-Server.
 * Copyright (C) 2012 NetModule AG
 */
 
void usage () {
    printf("usage: opcua-read.are <opcuaserver> <nodeIndex> <nodeId>\n");
    exit(1);
}
 
if (argc != 4) {
    usage();
}
 
opcuaserver = argv[1];
nodeIndex = (int) argv[2];
nodeId = (int) argv[3];
 
client_0 = nb_opcua_connect(opcuaserver);
if(client_0 >= 0) {
	ret = nb_opcua_read(client_0, nodeIndex, nodeId);
	if(ret < 0) {
		printf("could not read value of Node Index: %d, Id: %d \n",nodeIndex, nodeId);
	} else {
		printf("succesfully connected and read the value from %d\n", ret);
	}
	nb_opcua_disconnect(client_0);
} else {
	printf("could not connect to server %s\n", opcuaserver);
}
 
exit(0);