PubSub UADP : No of targetVariables (1) does not match Number of fields (40) - SOLVED, but has warnings
Description
I followed the example given in github and modified to fit my use case of 40 variables.
#define NO_OF_FIELDS 40
-
I configured the dataSetReader with 40 variables: dataSetReaderConfig.subscribedDataSet.subscribedDataSetTarget.targetVariablesSize = NO_OF_FIELDS;
-
I also configured pMetaData->fieldsSize= 40: pMetaData->fieldsSize = (size_t)NO_OF_FIELDS;
During execution, i get this error: warn/pubsub ReaderGroup ns=1;i=55279 | Reader ns=1;i=55285 | Number of fields does not match the TargetVariables configuration
Upon inspecting, i get a. TargetVariables = 1 b. Number of fields = 40
After tracing the code, a. in pubsub/ua_pubsub_reader.c, in UA_Server_addDataSetReader(), i get dataSetReaderConfig.subscribedDataSet.subscribedDataSetTarget.targetVariablesSize = 40
b. in the same file, in UA_DataSetReader_create(), i get dataSetReaderConfig->subscribedDataSet.subscribedDataSetTarget.targetVariablesSize = 40
i also went through the whole file (ua_pubsub_reader.c) to look for any statement that resemble ???targetVariablesSize = 1;
But I can't find any. So i don't know why is this field 'targetVariablesSize' was changed from 40 to 1 during runtime, and hence the error ocurred.
Please help.
Background Information / Reproduction Steps
Used CMake options:
cmake -DUA_NAMESPACE_ZERO=<YOUR_OPTION> <ANY_OTHER_OPTIONS> ..
sudo cmake -G Ninja .. -DCMAKE_C_COMPILER=/usr/local/gcc14.2.0/bin/gcc14.2.0 -DCMAKE_C_COMPILER_AR=/usr/local/gcc14.2.0/bin/gcc-ar14.2.0 -DCMAKE_C_COMPILER_RANLIB=/usr/local/gcc14.2.0/bin/gcc-ranlib14.2.0 -DOPENSSL_CRYPTO_LIBRARY=/usr/local/ssl/lib64/libcrypto.so -DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include -DOPENSSL_SSL_LIBRARY=/usr/local/ssl/lib64/libssl.so -DUA_ARCHITECTURE=posix -DUA_DEBUG_FILE_LINE_INFO=ON -DUA_ENABLE_AMALGAMATION=OFF -DBUILD_SHARED_LIBS=OFF -DUA_ENABLE_DA=ON -DUA_ENABLE_DATATYPES_ALL=ON -DUA_ENABLE_DEBUG_SANITIZER=OFF -DUA_ENABLE_DIAGNOSTICS=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_ENABLE_DISCOVERY_SEMAPHORE=ON -DUA_ENABLE_ENCRYPTION=OPENSSL -DUA_ENABLE_ENCRYPTION_OPENSSL=ON -DUA_ENABLE_HISTORIZING=ON -DUA_ENABLE_JSON_ENCODING=ON -DUA_ENABLE_MALLOC_SINGLETON=OFF -DUA_ENABLE_METHODCALLS=ON -DUA_ENABLE_MQTT=ON -DUA_ENABLE_NODEMANAGEMENT=ON -DUA_ENABLE_NODESETLOADER=OFF -DUA_ENABLE_NODESET_COMPILER_DESCRIPTIONS=ON -DUA_ENABLE_PARSING=ON -DUA_ENABLE_PUBSUB=ON -DUA_ENABLE_PUBSUB_BUFMALLOC=OFF -DUA_ENABLE_PUBSUB_ENCRYPTION=ON -DUA_ENABLE_PUBSUB_FILE_CONFIG=ON -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON -UA_ENABLE_PUBSUB_MONITORING=ON -UA_ENABLE_PUBSUB_SKS=OFF -DUA_ENABLE_STATUSCODE_DESCRIPTIONS=ON -DUA_ENABLE_SUBSCRIPTIONS=ON -DUA_ENABLE_SUBSCRIPTIONS_ALARMS=OFF -DUA_ENABLE_SUBSCRIPTIONS_EVENTS=ON -DUA_ENABLE_TYPEDESCRIPTION=ON -DUA_ENABLE_XML_ENCODING=ON -DUA_FORCE_WERROR=ON -DUA_LOGLEVEL=100 -DUA_MULTITHREADING=100 -DUA_NAMESPACE_ZERO=FULL -DUA_NODESET_DIR=/home/pi/open62541/deps/ua-nodeset
Checklist
Please provide the following information:
- [X ] open62541 Version (release number or git tag): v.1.4.14
- [ ] Other OPC UA SDKs used (client or server):
- [X ] Operating system: debian bookworm
- [ ] Logs (with
UA_LOGLEVELset as low as necessary) attached - [ ] Wireshark network dump attached
- [ ] Self-contained code example attached
- [X ] Critical issue
Resolved. The examples given are based on only 1 Field variable.
To make the code work for 40 field variables, i did the following:
- create an array of type UA_FieldTargetVariable with 40 elements i.e. UA_FieldTargetVariable AllTargetVar[40]
- every time a variable is created, copy the contents to AllTargetVar[]
- When all variables are created and saved to AllTargetVar[], call UA_Server_DataSetReader_createTargetVariables(server, readerId, NoOfVariables, AllTargetVar)
Hope this helps.
I get these message:
warn/pubsub ReaderGroup ns=1;i=55279 | Reader ns=1;i=55285 | DataSetMessage is discarded: Only keyframes are supported warn/pubsub ReaderGroup ns=1;i=55279 | Reader ns=1;i=55285 | DataSetMessage is discarded: Only keyframes are supported warn/pubsub ReaderGroup ns=1;i=55279 | Reader ns=1;i=55285 | DataSetMessage is discarded: Only keyframes are supported ....
what does it mean? How to resolve this warning?
I set
- dataSetWriterConfig.KeyFrameCount = 10
- UA_NetworkAddressUrlDataType networkAddressUrlUdp = {UA_STRING_NULL, UA_STRING(NETWORKADDRESSURL_PROTOCOL_UDP)}; //"opc.udp://224.0.0.22:4840/")};
This is what I get using wireshark
Besides key-frames there are also delta-frames. Which contain only the changed fields.
This is described in the opc UA Standard Part 14.
Do you receive the messages from a different publisher / not open62541?
nope. only 1 instance of the server is running. both uaExpert and matrikon ua clients are not connected to the server when the message appeared.