Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: etElMadr on September 04, 2021, 02:47:54 PM
-
Using Node Red to send a JSON to BRX PLC: {"on":false, "bri":0} Have PacketIn and JSONparse
1) Sending string formated as a JSON object to PLC works fine. I can JSONparse the string
2) Sending JSON object to PLC, PLC isn't decoding the object. In the Memory View for the PacketInBuffer, ASCII view: [object Object]":0}
Not sure what to do. Can PLC interprete the JSON Object, and if so, how?
Thank You
-
Using Node Red to send a JSON to BRX PLC: {"on":false, "bri":0} Have PacketIn and JSONparse
1) Sending string formated as a JSON object to PLC works fine. I can JSONparse the string
2) Sending JSON object to PLC, PLC isn't decoding the object. In the Memory View for the PacketInBuffer, ASCII view: [object Object]":0}
Not sure what to do. Can PLC interprete the JSON Object, and if so, how?
Thank You
The JSON record you are trying to parse isn't valid. Somewhere in the process the record is getting corrupted.
-
Thanks. Are you familiar with Node Red? The following will make more sense if you are.
I setup a Node Red flow with an Inject node and UDP out node. If the Inject Node injects {"on":false, "bri":0} as a string, the PacketIn receives the sting and I can parse it with the JSONparse. If the Inject Node injects {"on":false, "bri":0} as a JSON Object, the PacketIn receives 30 bytes of integers but JSONparse doesn't know what to do with it. If the Inject Node injects {"off":true, "bri":0} as a JSON Object, the PacketIn receives the same 30 bytes of integers (no change). In fact, it doesn't seem to matter what the JSON object content is, PacketIn always gets the same 30 bytes.
While I understand the higher level concept of UDP, I don't understand whats going on at the lower levels so I'm not sure how to diagnose the issue.
-
UDP is simply returning the raw data sent in the packet. If the packet contains a valid JSON record, the PLC can parse it, but what you showed earlier was not a valid JSON record. It looked like a couple of different things overlapping. If you can capture the UDP packet coming from Node Red with WireShark, I'm happy to see if I can tell you what may be going wrong.