Leon Urbas 11 years ago
parent
commit
69e3fe29c0
4 changed files with 18 additions and 7 deletions
  1. 1 2
      src/opcua_binaryEncDec.c
  2. 6 0
      src/opcua_builtInDatatypes.h
  3. 1 1
      src/opcua_types.h
  4. 10 4
      tests/check_stack.c

+ 1 - 2
src/opcua_binaryEncDec.c

@@ -1489,8 +1489,7 @@ Int32 encodeResponseHeader(UA_AD_ResponseHeader const * responseHeader,
 	return 0;
 }
 Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject) {
-	Int32 length;
-	Byte mask;
+	Int32 length = 0;
 
 	length += nodeId_calcSize(&(extensionObject->TypeId));
 	length += sizeof(Byte); //The EncodingMask Byte

+ 6 - 0
src/opcua_builtInDatatypes.h

@@ -301,6 +301,12 @@ UA_ExpandedNodeId;
 * Page: 20
 */
 typedef UInt32 UA_StatusCode;
+typedef enum UA_StatusCodes
+{
+	// Some Values are called the same as previous Enumerations so we need
+	//names that are unique
+	SC_Good 			= 			0x00
+} UA_StatusCodes;
 
 
 /**

+ 1 - 1
src/opcua_types.h

@@ -800,7 +800,7 @@ UA_AD_RequestReturnDiagnositcs;
 * Chapter: 7.27
 * Page: 133
 */
-typedef struct
+typedef struct UA_AD_ResponseHeader
 {
 	UA_DateTime timestamp;
 	UA_AD_IntegerId requestHandle;

+ 10 - 4
tests/check_stack.c

@@ -451,17 +451,23 @@ START_TEST(extensionObject_calcSize_test)
 	Byte data[3] = {1,2,3};
 	UA_ExtensionObject extensionObject;
 
+	// empty ExtensionObject
 	extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;; // Numeric TWO BYTES
 	extensionObject.TypeId.Identifier.Numeric = 0;
-
-	extensionObject.Encoding = 0x00;
-	extensionObject.Length = 0;
-	//extensionObject.Body = &data;
+	extensionObject.Encoding = NO_BODY_IS_ENCODED;
 
 	valcalc = extensionObject_calcSize(&extensionObject);
 	valreal = 3;
 	ck_assert_int_eq(valcalc, valreal);
 
+	// ExtensionObject with ByteString-Body
+	extensionObject.Encoding = BODY_IS_BYTE_STRING;
+	extensionObject.Body.Data = data;
+	extensionObject.Body.Length = 3;
+	valcalc = extensionObject_calcSize(&extensionObject);
+	valreal = 3 + 4 + 3;
+	ck_assert_int_eq(valcalc, valreal);
+
 }
 END_TEST