Browse Source

another change within the array encode function

FlorianPalm 10 years ago
parent
commit
3c261a67d0
2 changed files with 10 additions and 6 deletions
  1. 1 1
      src/ua_services_attribute.c
  2. 9 5
      src/ua_types_encoding_binary.c

+ 1 - 1
src/ua_services_attribute.c

@@ -247,6 +247,6 @@ UA_Int32 Service_Read(SL_Channel *channel, const UA_ReadRequest *request,
 		                                         &request->nodesToRead[i]);
 	}
 	response->responseHeader.serviceResult = UA_STATUSCODE_GOOD;
-	response->diagnosticInfosSize = -1;
+	response->diagnosticInfosSize = 0;
 	return UA_SUCCESS;
 }

+ 9 - 5
src/ua_types_encoding_binary.c

@@ -24,12 +24,16 @@ UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, UA_VTable_Entry *vt, const
 
 UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, UA_ByteString *dst,
                                UA_UInt32 *offset) {
-	if(vt == UA_NULL || dst == UA_NULL || offset == UA_NULL)
+	if(vt == UA_NULL || dst == UA_NULL || offset == UA_NULL || (src == UA_NULL && noElements > 0))
 		return UA_ERROR;
-	if(src == UA_NULL) //Null Arrays are encoded with length = -1 // part 6 - §5.24
-	{
-		noElements = -1;
-	}
+
+
+//	if(src == UA_NULL && noElements >) //Null Arrays are encoded with length = -1 // part 6 - §5.24
+//	{
+//		noElements = -1;
+//	}
+
+
 	UA_Int32 retval     = UA_SUCCESS;
 	retval = UA_Int32_encodeBinary(&noElements, dst, offset);
 	const UA_Byte *csrc = (const UA_Byte *)src;