News:

  • October 16, 2026, 06:28:24 PM

Login with username, password and session length

Author Topic: UDP (PacketIn) JSON Object  (Read 7970 times)

etElMadr

  • Full Member
  • ***
  • Posts: 37
UDP (PacketIn) JSON Object
« 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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6177
  • Yes Pinky, Do-more will control the world!
Re: UDP (PacketIn) JSON Object
« Reply #1 on: September 04, 2021, 02:57:33 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

The JSON record you are trying to parse isn't valid. Somewhere in the process the record is getting corrupted.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

etElMadr

  • Full Member
  • ***
  • Posts: 37
Re: UDP (PacketIn) JSON Object
« Reply #2 on: September 04, 2021, 06:35:28 PM »
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.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6177
  • Yes Pinky, Do-more will control the world!
Re: UDP (PacketIn) JSON Object
« Reply #3 on: September 04, 2021, 07:02:41 PM »
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.

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO