Browse Source

example server: disallow writing values of any type

by setting the dataType in the node (and not just in the variant)
Julius Pfrommer 8 years ago
parent
commit
29a241db58
2 changed files with 2 additions and 1 deletions
  1. 1 0
      examples/server.c
  2. 1 1
      src/server/ua_services_attribute.c

+ 1 - 0
examples/server.c

@@ -249,6 +249,7 @@ int main(int argc, char** argv) {
         UA_VariableAttributes attr;
         UA_VariableAttributes_init(&attr);
         attr.valueRank = -2;
+        attr.dataType = UA_TYPES[type].typeId;
 #ifndef UA_ENABLE_TYPENAMES
         char name[15];
 #if defined(_WIN32) && !defined(__MINGW32__)

+ 1 - 1
src/server/ua_services_attribute.c

@@ -520,7 +520,7 @@ UA_Variant_matchVariableDefinition(UA_Server *server, const UA_NodeId *variableD
            dimensions are checked later */
         if(variableDataType == &UA_TYPES[UA_TYPES_BYTE] &&
            valueDataType == &UA_TYPES[UA_TYPES_BYTESTRING] &&
-           !range && !UA_Variant_isScalar(value)) {
+           !range && UA_Variant_isScalar(value)) {
             UA_ByteString *str = (UA_ByteString*)value->data;
             editableValue->type = &UA_TYPES[UA_TYPES_BYTE];
             editableValue->arrayLength = str->length;