Procházet zdrojové kódy

merge generate_namespace finished but namespace broken

Example: asked for node with nodeId={i=2256}, got node with
nodeId={i=3168},BrowseName= {Length=13, Data=AddNodesCount}
Leon Urbas před 10 roky
rodič
revize
6c8d59c0ad
3 změnil soubory, kde provedl 32 přidání a 12 odebrání
  1. 5 1
      examples/src/xml2ns0.c
  2. 3 5
      src/ua_basictypes.c
  3. 24 6
      src/ua_xml.c

+ 5 - 1
examples/src/xml2ns0.c

@@ -32,6 +32,10 @@ void sam_attach(Namespace *ns,UA_Int32 ns0id,UA_Int32 type, void* p) {
 	nodeid.encodingByte = UA_NODEIDTYPE_FOURBYTE;
 	const UA_Node* result;
 	Namespace_get(ns,&nodeid,&result,&lock);
+
+	printf("asked for node with nodeId={i=%d}, got node with nodeId={i=%d},",ns0id, result->nodeId.identifier.numeric);
+	UA_String_printf("BrowseName=",&(result->browseName.name));
+
 	if (result->nodeClass == UA_NODECLASS_VARIABLE) {
 		UA_VariableNode* variable = (UA_VariableNode*) result;
 		if (variable->dataType.identifier.numeric == UA_[type].ns0Id) {
@@ -58,7 +62,7 @@ void sam_attach(Namespace *ns,UA_Int32 ns0id,UA_Int32 type, void* p) {
 				}
 			}
 		} else {
-			printf("wrong nodeId for id=%d, got=%d, expected=%d\n", ns0id, UA_[type].ns0Id, variable->dataType.identifier.numeric);
+			printf("wrong datatype for id=%d, expected=%d, retrieved=%d\n", ns0id, UA_[type].ns0Id, variable->dataType.identifier.numeric);
 		}
 	} else {
 		perror("Namespace_getWritable returned wrong node class");

+ 3 - 5
src/ua_basictypes.c

@@ -357,7 +357,7 @@ UA_TYPE_METHOD_COPY(UA_Float)
 UA_TYPE_METHOD_DECODEXML_NOTIMPL(UA_Float)
 
 
-/** UA_Float - IEEE754 64bit float with biased exponent*/
+/** UA_Double - IEEE754 64bit float with biased exponent*/
 UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Double)
 // FIXME: Implement NaN, Inf and Zero(s)
 UA_Byte UA_DOUBLE_ZERO[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
@@ -1344,7 +1344,6 @@ UA_Int32 UA_QualifiedName_init(UA_QualifiedName * p) {
 	if(p==UA_NULL)return UA_ERROR;
 	UA_String_init(&(p->name));
 	p->namespaceIndex=0;
-	//p->reserved=0;
 	return UA_SUCCESS;
 }
 UA_TYPE_METHOD_NEW_DEFAULT(UA_QualifiedName)
@@ -1353,7 +1352,6 @@ UA_Int32 UA_QualifiedName_copy(UA_QualifiedName const *src, UA_QualifiedName *ds
 	retval |= UA_alloc((void**)&dst,UA_QualifiedName_calcSize(UA_NULL));
 	retval |= UA_String_copy(&(src->name),&(dst->name));
 	retval |= UA_UInt16_copy(&(src->namespaceIndex),&(dst->namespaceIndex));
-	//retval |= UA_UInt16_copy(&(src->reserved),&(dst->reserved));
 	return retval;
 
 }
@@ -1361,11 +1359,11 @@ UA_Int32 UA_QualifiedName_copy(UA_QualifiedName const *src, UA_QualifiedName *ds
 UA_Int32 UA_Variant_calcSize(UA_Variant const * p) {
 	UA_Int32 length = 0;
 	if (p == UA_NULL) return sizeof(UA_Variant);
-	UA_UInt32 ns0Id = p->encodingMask & 0x1F; // Bits 1-5
+	UA_UInt32 builtinNs0Id = p->encodingMask & 0x3F; // Bits 0-5
 	UA_Boolean isArray = p->encodingMask & (0x01 << 7); // Bit 7
 	UA_Boolean hasDimensions = p->encodingMask & (0x01 << 6); // Bit 6
 
-	if (p->vt == UA_NULL || ns0Id != p->vt->ns0Id) return UA_ERR_INCONSISTENT;
+	if (p->vt == UA_NULL || builtinNs0Id != p->vt->ns0Id) return UA_ERR_INCONSISTENT;
 	length += sizeof(UA_Byte); //p->encodingMask
 	if (isArray) { // array length is encoded
 		length += sizeof(UA_Int32); //p->arrayLength

+ 24 - 6
src/ua_xml.c

@@ -714,7 +714,7 @@ UA_Int32 UA_VariableNode_decodeXML(XML_Stack* s, XML_Attr* attr, UA_VariableNode
 			}
 		}
 	} else {
-		if (s->parent[s->depth - 1].activeChild == 5 && attr != UA_NULL) {
+		if (s->parent[s->depth - 1].activeChild == 5 && attr != UA_NULL) { // References
 			UA_TypedArray* array = (UA_TypedArray*) attr;
 			DBG(printf("UA_VariableNode_decodeXML - finished references=%p, size=%d\n",(void*)array,(array==UA_NULL)?-1:array->size));
 			dst->referencesSize = array->size;
@@ -756,11 +756,29 @@ void print_node(UA_Node const * node) {
 			printf("\t.value.type.name=%s\n", p->value.vt->name);
 			printf("\t.value.array.length=%d\n", p->value.arrayLength);
 			UA_Int32 i;
-			for (i=0;i<p->value.arrayLength;i++) {
-				printf("\t.value.array.element[%d]=%p", i, p->value.data[i]);
-				if (p->value.vt->ns0Id == UA_LOCALIZEDTEXT_NS0) {
-					UA_LocalizedText* ltp = (UA_LocalizedText*) p->value.data[i];
-					printf(",enc=%d,locale={%d,{%.*s}},text={%d,{%.*s}}",ltp->encodingMask,ltp->locale.length,ltp->locale.length,ltp->locale.data,ltp->text.length,ltp->text.length,ltp->text.data);
+			for (i=0;i<p->value.arrayLength || (p->value.arrayLength==-1 && i==0);++i) {
+				printf("\t.value.array.element[%d]=%p", i, (p->value.data == UA_NULL ? UA_NULL : p->value.data[i]));
+				switch (p->value.vt->ns0Id) {
+				case UA_LOCALIZEDTEXT_NS0: {
+					if (p->value.data != UA_NULL) {
+						UA_LocalizedText* ltp = (UA_LocalizedText*) p->value.data[i];
+						printf(",enc=%d,locale={%d,{%.*s}},text={%d,{%.*s}}",ltp->encodingMask,ltp->locale.length,ltp->locale.length,ltp->locale.data,ltp->text.length,ltp->text.length,ltp->text.data);
+					}
+				}
+				break;
+				case UA_EXTENSIONOBJECT_NS0: {
+					if (p->value.data != UA_NULL) {
+						UA_ExtensionObject* eo = (UA_ExtensionObject*) p->value.data[i];
+						if (eo == UA_NULL) {
+							printf(",(null)");
+						} else {
+							printf(",enc=%d,typeId={i=%d}",eo->encoding,eo->typeId.identifier.numeric);
+						}
+					}
+				}
+				break;
+				default:
+				break;
 				}
 				printf("\n");
 			}