Closed Fabi00815 closed 3 months ago
Hi!
Yes, if there were any ads errors you get them into the twincat runtime. All other errors can be debugged by activating the logging.
You can put the log.config near to the exe in the c:/twincat/functions/jsonreadwriter folder and look for what get written there when you call the method.
Did you used the attribute defined in the Readme for your structures?
Best regards, FB
Hey,
thanks for your fast response!
Here the Log Output. (First Step i tryed to Write and it works successfully, Second Step Read and it didnt work)
The Variable is defined like this:
{attribute 'json' := 'Variable'}
Variable : INT;
`[23.05. 08:31:19.757] DEBUG - Program+
[23.05. 08:32:14.360] DEBUG - Program+1.<WriteAsync>b__0() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei TwinCAT.JsonExtension.AdsClientExtensions.<WriteRecursive>d__13.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei TFU003.Program.<OnExecute>d__25.MoveNext() [23.05. 08:32:15.906] ERROR - Program+<OnExecute>d__25.MoveNext - bei Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value) bei Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) bei TwinCAT.JsonExtension.AdsClientExtensions.<>c__DisplayClass1_0
1.
Hi!
Ok, I got it.
The error is: Error while calling Json Parser: System.ArgumentException: Can not convert Object to Int16
.
Here the reason why this happens:
As you write to file you transmit a single value => the library wrap it up to an object (in order to create a valid json file) containing one Property.
When you read back the file you get an object, that of course cannot be parsed to a sigle field in the plc.
Solution: create a DUT with some fields inside. Use the json attribute for each field inside the DUT as you already did. Then serialize to file the variable containig the whole dut => this will be a json object. When you read it back from json it shouldn't throw any further exception because the software is able to match the object correctly.
Let me know if it works.
Best regards, FB
That worked perfekt.
Thank you for the projekt and for the fast support! Nice!
Welcome
Hello,
i am trying to get your parser run.
If im trying to write it works perfekt. The Value in Twincat is written perfekt to the json File.
But if i want to read the same json File back to the same Variable in Twincat it doenst work.
Any Ideas?
There is no Error ID or something present?
Thanks!