{"action":"closed","issue":{"url":"https://api.github.com/repos/open62541/open62541/issues/1737","repository_url":"https://api.github.com/repos/open62541/open62541","labels_url":"https://api.github.com/repos/open62541/open62541/issues/1737/labels{/name}","comments_url":"https://api.github.com/repos/open62541/open62541/issues/1737/comments","events_url":"https://api.github.com/repos/open62541/open62541/issues/1737/events","html_url":"https://github.com/open62541/open62541/issues/1737","id":313719786,"number":1737,"title":"Method call returns seemingly random value","user":{"login":"genericFJS","id":3334361,"avatar_url":"https://avatars2.githubusercontent.com/u/3334361?v=4","gravatar_id":"","url":"https://api.github.com/users/genericFJS","html_url":"https://github.com/genericFJS","followers_url":"https://api.github.com/users/genericFJS/followers","following_url":"https://api.github.com/users/genericFJS/following{/other_user}","gists_url":"https://api.github.com/users/genericFJS/gists{/gist_id}","starred_url":"https://api.github.com/users/genericFJS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genericFJS/subscriptions","organizations_url":"https://api.github.com/users/genericFJS/orgs","repos_url":"https://api.github.com/users/genericFJS/repos","events_url":"https://api.github.com/users/genericFJS/events{/privacy}","received_events_url":"https://api.github.com/users/genericFJS/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-04-12T13:09:05Z","updated_at":"2018-04-13T08:15:42Z","closed_at":"2018-04-13T08:15:42Z","author_association":"NONE","body":"Description\r\n===========\r\nI tried writing a function call according to the given [example](https://github.com/open62541/open62541/blob/master/examples/client.c). I added code from the [tutorial](https://open62541.org/doc/0.3/tutorial_client_firststeps.html) to verify that the basics are working.\r\nI want to call the method `ReadVar` with the argument `/plc/db2001.dbb39`:\r\n![readvar](https://user-images.githubusercontent.com/3334361/38678764-47948e9c-3e62-11e8-8f77-6d0c0fe60b6b.PNG)\r\nI am using `UA_Client_call(client,\r\n\t\tUA_NODEID_STRING(2, \"/Methods\"),\r\n\t\tUA_NODEID_STRING(2, \"/Methods/ReadVar\"),\r\n\t\t1, &input, &outputSize, &output)` (full example below).\r\nI expect the output `4`. But I get two random numbers followed by 9990… for example 439990 or 309000.\r\nNote that the server is working (it works in C# using [open-ua-client](https://github.com/convertersystems/opc-ua-client) and with the UA SDK). The UA SDK example:\r\n![uasdk](https://user-images.githubusercontent.com/3334361/38678765-47dabd4a-3e62-11e8-8d93-e395d5ab096d.PNG)\r\n\r\nWhat am I is going wrong?\r\n\r\nMy code:\r\n\r\n```c\r\n#include <stdio.h>\r\n#include \"open62541/open62541.h\"\r\n\r\nint main(void) {\r\n\tUA_Client *client = UA_Client_new(UA_ClientConfig_default);\r\n\tUA_StatusCode retval = UA_Client_connect(client, \"opc.tcp://10.1.21.31:4840\");\r\n\tif (retval != UA_STATUSCODE_GOOD) {\r\n\t\tUA_Client_delete(client);\r\n\t\treturn (int)retval;\r\n\t}\r\n\r\n\tUA_Variant value;\r\n\tUA_Variant_init(&value);\r\n\r\n\t/* NodeId of the variable holding the current time */\r\n\tconst UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);\r\n\tretval = UA_Client_readValueAttribute(client, nodeId, &value);\r\n\r\n\tif (retval == UA_STATUSCODE_GOOD && UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {\r\n\t\tUA_DateTime raw_date = *(UA_DateTime *)value.data;\r\n\t\tUA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);\r\n\t\tUA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, \"date is: %u-%u-%u %u:%u:%u.%03u\\n\",\r\n\t\t\tdts.day, dts.month, dts.year, dts.hour, dts.min, dts.sec, dts.milliSec);\r\n\t}\r\n\t/* Clean up */\r\n\tUA_Variant_deleteMembers(&value);\r\n\r\n\t/* Call a remote method */\r\n\tUA_Variant input;\r\n\tUA_String argString = UA_STRING(\"/plc/db2001.dbb39\");\r\n\tUA_Variant_init(&input);\r\n\tUA_Variant_setScalarCopy(&input, &argString, &UA_TYPES[UA_TYPES_STRING]);\r\n\tsize_t outputSize;\r\n\tUA_Variant *output;\r\n\tretval = UA_Client_call(client,\r\n\t\tUA_NODEID_STRING(2, \"/Methods\"),\r\n\t\tUA_NODEID_STRING(2, \"/Methods/ReadVar\"),\r\n\t\t1, &input, &outputSize, &output);\r\n\tif (retval == UA_STATUSCODE_GOOD) {\r\n\t\tprintf(\"Method call was successfull, and %lu returned values available.\\n\",\r\n\t\t\t(unsigned long)outputSize);\r\n\t\tprintf(\"\\tExpected Output: %hhx\\n\", '4');\r\n\t\tprintf(\"\\t         Output: %x\\n\", output);\r\n\t\tUA_Array_delete(output, outputSize, &UA_TYPES[UA_TYPES_VARIANT]);\r\n\t} else {\r\n\t\tprintf(\"Method call was unsuccessfull, and %x returned values available.\\n\", retval);\r\n\t}\r\n\tUA_Variant_deleteMembers(&input);\r\n\r\n\t/*\r\n\tWorking method request in C# using https://github.com/convertersystems/opc-ua-client:\r\n\t\tnew CallMethodRequest {\r\n\t\t\tObjectId = NodeId.Parse(\"ns=2;s=/Methods\"),\r\n\t\t\tMethodId = NodeId.Parse(\"ns=2;s=/Methods/ReadVar\"),\r\n\t\t\tInputArguments = new Variant[1] { \"/plc/db2001.dbb39\" }\r\n\t\t}\r\n\t*/\r\n\r\n\tUA_Client_delete(client); /* Disconnects the client internally */\r\n\treturn UA_STATUSCODE_GOOD;\r\n}\r\n```\r\n\r\nChecklist\r\n=========\r\nPlease provide the following information:\r\n\r\n - [x] open62541 Version (release number or git tag):\r\n0.3rc1\r\n - [x] Other OPC UA SDKs used (client or server): \r\nSinumerik server; https://github.com/convertersystems/opc-ua-client and UA SDK for verification/testing\r\n - [x] Operating system:\r\nWindows 7 64bit with MSVS2017\r\n - [x] Self-contained code example attached\r\n - [ ] Critical issue\r\n\r\n\r\n"}}
{"actor":{"display_login":"genericFJS"}}