Forráskód Böngészése

Fixed conflict arising from the lack of calcSizeBinary in the master branch.

ichrispa 9 éve
szülő
commit
69892b53f0
2 módosított fájl, 12 hozzáadás és 11 törlés
  1. 11 11
      src/client/ua_client.c
  2. 1 0
      src/ua_types_encoding_binary.h

+ 11 - 11
src/client/ua_client.c

@@ -600,15 +600,15 @@ UA_DeleteReferencesResponse UA_Client_deleteReferences(UA_Client *client, UA_Del
     REQUEST.nodesToAddSize = 1;                                                           \
     } while(0)
     
-#define ADDNODES_PACK_AND_SEND(PREQUEST,PATTRIBUTES,PNODETYPE) do {                                                                     \
-    PREQUEST.nodesToAdd[0].nodeAttributes.encoding = UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISBYTESTRING;                                  \
-    PREQUEST.nodesToAdd[0].nodeAttributes.typeId   = UA_NODEID_NUMERIC(0, UA_NS0ID_##PNODETYPE##ATTRIBUTES + UA_ENCODINGOFFSET_BINARY); \
-    PREQUEST.nodesToAdd[0].nodeAttributes.body.length = UA_calcSizeBinary(&PATTRIBUTES, &UA_TYPES[UA_TYPES_##PNODETYPE##ATTRIBUTES]);   \
-    PREQUEST.nodesToAdd[0].nodeAttributes.body.data = (void *) malloc(PREQUEST.nodesToAdd[0].nodeAttributes.body.length);               \
-    size_t encOffset = 0;                                                                                                               \
-    UA_encodeBinary(&PATTRIBUTES,&UA_TYPES[UA_TYPES_##PNODETYPE##ATTRIBUTES], &(PREQUEST.nodesToAdd[0].nodeAttributes.body), &encOffset);       \
-    *(adRes) = UA_Client_addNodes(client, &PREQUEST);                                                                                   \
-    UA_AddNodesRequest_deleteMembers(&PREQUEST);                                                                                        \
+#define ADDNODES_PACK_AND_SEND(PREQUEST,PATTRIBUTES,PNODETYPE) do {                                                                       \
+    PREQUEST.nodesToAdd[0].nodeAttributes.encoding = UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISBYTESTRING;                                    \
+    PREQUEST.nodesToAdd[0].nodeAttributes.typeId   = UA_NODEID_NUMERIC(0, UA_NS0ID_##PNODETYPE##ATTRIBUTES + UA_ENCODINGOFFSET_BINARY);   \
+    size_t encOffset = 0;                                                                                                                 \
+    UA_ByteString_newMembers(&PREQUEST.nodesToAdd[0].nodeAttributes.body, client->connection.remoteConf.maxMessageSize);                  \
+    UA_encodeBinary(&PATTRIBUTES,&UA_TYPES[UA_TYPES_##PNODETYPE##ATTRIBUTES], &(PREQUEST.nodesToAdd[0].nodeAttributes.body), &encOffset); \
+    PREQUEST.nodesToAdd[0].nodeAttributes.body.length = encOffset;                                                                                 \
+    *(adRes) = UA_Client_addNodes(client, &PREQUEST);                                                                                     \
+    UA_AddNodesRequest_deleteMembers(&PREQUEST);                                                                                          \
 } while(0)
     
 /* NodeManagement */
@@ -635,8 +635,8 @@ UA_AddNodesResponse *UA_Client_createObjectNode(UA_Client *client, UA_ExpandedNo
     vAtt.eventNotifier       = 0;
     vAtt.specifiedAttributes |= UA_NODEATTRIBUTESMASK_EVENTNOTIFIER;
 
-    ADDNODES_PACK_AND_SEND(adReq,vAtt,OBJECT);
-
+    ADDNODES_PACK_AND_SEND(adReq,vAtt,OBJECT); 
+    
     return adRes;
 }
 

+ 1 - 0
src/ua_types_encoding_binary.h

@@ -61,6 +61,7 @@ UA_TYPE_BINARY_ENCODING(UA_DiagnosticInfo)
 UA_StatusCode UA_encodeBinary(const void *src, const UA_DataType *dataType, UA_ByteString *dst,
                               size_t *UA_RESTRICT offset);
 UA_StatusCode UA_decodeBinary(const UA_ByteString *src, size_t * UA_RESTRICT offset, void *dst,
+                              const UA_DataType *dataType);
 /// @}
 
 #endif /* UA_TYPES_ENCODING_BINARY_H_ */