

9:12, EEST
July 25, 2017

Hello ,
I have to read data from server using a client code which i have developed in VS c++ . I want to know if i can pass a variable in the server node to read instead of hardcoding it.
I am pasting the sample code below.
I am getting BadIDUnkown as the output. Please HELP!!
UaStatus result;
ServiceSettings serviceSettings;
UaReadValueIds nodeToRead;
UaDataValues values;
UaDiagnosticInfos diagnosticInfos;
// Configure one node to read
// We read the value of the ServerStatus -> CurrentTime
nodeToRead.create(1);
nodeToRead[0].AttributeId = OpcUa_Attributes_Value;
nodeToRead[0].NodeId.Identifier.Numeric = OpcUaId_Server_ServerStatus_CurrentTime; //This works fine
nodeToRead[0].NodeId.Identifier.Numeric = (int) settings.currentTime; //But, this gives an ERROR. settings.currentTime is a charecter array inside a structure. It contains “OpcUaId_Server_ServerStatus_CurrentTime” but I am not able to read this.
printf(“
Reading …
“);
result = m_pSession->read(
serviceSettings,
0,
OpcUa_TimestampsToReturn_Both,
nodeToRead,
values,
diagnosticInfos);
if (result.isGood())
{
// Read service succeded – check status of read value
if (OpcUa_IsGood(values[0].StatusCode))
{
printf(“ServerStatus_State: %s
“, UaVariant(values[0].Value).toString().toUtf8());
}
else
{
printf(“Read failed for item[0] with status %s
“, UaStatus(values[0].StatusCode).toString().toUtf8());
}
}
else
{
// Service call failed
printf(“Read failed with status %s
“, result.toString().toUtf8());
}
15:51, EEST

December 21, 2011

7:05, EEST
July 25, 2017

Most Users Ever Online: 518
Currently Online:
11 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
hbrackel: 130
pramanj: 86
Francesco Zambon: 78
ibrahim: 75
rocket science: 73
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
fred: 41
Member Stats:
Guest Posters: 0
Members: 666
Moderators: 16
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1430
Posts: 6119
Newest Members:
sophiedavis, anitas, fakenatty, Negansaf, rheakempton93, JPasterkamp, mattiwenell, KevinGainy, jamiescooper, lonmackellar61Moderators: Jouni Aro: 1002, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 954, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 297, Lusetti: 0, Ari-Pekka Soikkeli: 5
Administrators: admin: 1