Post by risele on Discussion for Home page
JSON parsing and composing library
home
(Post)
Just tested with your structs and seems JSON is perfectly valid. With root: {"biota":{"PLANT":[{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null}],"ANIMAL":[{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null}]}} Rootless: {"PLANT":[{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null}],"ANIMAL":[{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null}]} The code I used: PROGRAM PLC_PRG VAR biota: ST_BIOTA; converter,converter1: STRUCT_TO_JSON; xRun,xRun1:BOOL:=TRUE; JSONString: STRING(1000); JSONStringRootless: STRING(1000); END_VAR IF xRun THEN IF converter.Done OR converter.Error THEN xRun:=FALSE; END_IF END_IF IF xRun1 THEN IF converter1.Done OR converter1.Error THEN xRun1:=FALSE; END_IF END_IF converter(JSONVars:=ADR(biota),NumberOfVars:=SIZEOF(biota)/SIZEOF(JSONVAR), JSONString:= ADR(JSONString), JSONStringSize:= SIZEOF(JSONString), Execute:=xRun,Rootless:=FALSE); converter1(JSONVars:=ADR(biota),NumberOfVars:=SIZEOF(biota)/SIZEOF(JSONVAR), JSONString:= ADR(JSONStringRootless), JSONStringSize:= SIZEOF(JSONStringRootless), Execute:=xRun1,Rootless:=TRUE); UPD: for top-level described array it also provides valid output, BUT only with ROOTLESS=FALSE option. It's not an error, I suppose, since nameless array could not exists in JSON. For biota: ARRAY [1..3] OF ST_BIOTA; output is {"biota":[{"PLANT":[{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null}],"ANIMAL":[{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null}]},{"PLANT":[{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null}],"ANIMAL":[{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null}]},{"PLANT":[{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null},{"NAME":null,"QUANTITY":null}],"ANIMAL":[{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null},{"NAME":null,"AGE":null}]}]}
Last updated: 4 days ago
Ultrasonic sensor HC SR04
CODESYS Forge
talk
(Thread)
Ultrasonic sensor HC SR04
Last updated: 4 days ago
Control Omron G5 servo drive in Torque mode
CODESYS Forge
talk
(Thread)
Control Omron G5 servo drive in Torque mode
Last updated: 4 days ago
wiki Discussion
vvyn
wiki
(Discussion)
Forum for wiki comments
Last updated: 3 days ago
blog Discussion
vvyn
blog
(Discussion)
Forum for blog comments
Last updated: 3 days ago
(no subject)
vvyn
wiki
(Thread)
Last updated: 3 days ago
Home
vvyn
wiki
(WikiPage)
Project Members: vvyn (admin)
Last updated: 3 days ago
wiki Discussion
noah
wiki
(Discussion)
Forum for wiki comments
Last updated: 3 days ago
blog Discussion
noah
blog
(Discussion)
Forum for blog comments
Last updated: 3 days ago
(no subject)
noah
wiki
(Thread)
Last updated: 3 days ago
Home
noah
wiki
(WikiPage)
Project Members: noah (admin)
Last updated: 3 days ago
Post by noah on "Invalid Value" for Variables at Runtime
CODESYS Forge
talk
(Post)
Hello, I also have the problem that suddenly all variables in my project were invalid and shown as "???" during runtime. Could you manage to fix the problem in the last 4,5 years ;) ? Because I tried everythin to fix it but nothing worked. I feel like maybe this is a bug. Thank you.
Last updated: 3 days ago
"Invalid Value" for Variables at Runtime
CODESYS Forge
talk
(Thread)
"Invalid Value" for Variables at Runtime
Last updated: 3 days ago
blog Discussion
hhermsen
blog
(Discussion)
Forum for blog comments
Last updated: 3 days ago
Post by noah on "Invalid Value" for Variables at Runtime
CODESYS Forge
talk
(Post)
Hello, I also have the problem that suddenly all variables in my project were invalid and shown as "???" during runtime. Could you manage to fix the problem in the last 4,5 years ;) ? Because I tried everythin to fix it but nothing worked. I feel like maybe this is a bug. Thank you.
Last updated: 3 days ago
Home (version 1) discussion
oemcba
wiki
(Thread)
Home (version 1) discussion
Last updated: 3 days ago
wiki Discussion
hhermsen
wiki
(Discussion)
Forum for wiki comments
Last updated: 3 days ago
(no subject)
hhermsen
wiki
(Thread)
Last updated: 3 days ago
Home
hhermsen
wiki
(WikiPage)
Project Members: hhermsen (admin)
Last updated: 3 days ago
Escape character behavior for hex values in string -- what gives?
CODESYS Forge
talk
(Thread)
Escape character behavior for hex values in string -- what gives?
Last updated: 3 days ago
Home (version 1) discussion
noah
wiki
(Thread)
Home (version 1) discussion
Last updated: 3 days ago
Post by gordonkeller360 on Escape character behavior for hex values in string -- what gives?
CODESYS Forge
talk
(Post)
I have a program which sequentially places byte representations of characters from a string into an array. FUNCTION_BLOCK MoveBytesFromString VAR_IN_OUT abRxBuf: ARRAY [0..79] OF BYTE; END_VAR VAR testString : STRING := '$0A$R$L$TTesting,123...$94$86$0A'; iCount: DINT; END_VAR ---------------------------------------------------------------------------------------- // clear the buffer MEM.MemFill(ADR(abRxBuf), 80, 0); FOR iCount := 0 TO LEN(testString) - 1 DO // account for undesired null terminator of string abRxBuf[iCount] := testString[iCount]; END_FOR Escaped characters, like $T, $N, etc. work just fine, and so do their hex representation counterparts ($09, $0A, etc). However, when I put something like $94, I get a set of nonsense values... see image attached after one spin of the program. Could someone explain to me what is happening here? I'll continue to investigate...
Last updated: 3 days ago
wiki Discussion
gaga1
wiki
(Discussion)
Forum for wiki comments
Last updated: 2 days ago
blog Discussion
gaga1
blog
(Discussion)
Forum for blog comments
Last updated: 2 days ago
(no subject)
gaga1
wiki
(Thread)
Last updated: 2 days ago