Node Red payload buffers can't contain "binary" zeros

Home Forums General Node Red payload buffers can't contain "binary" zeros

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26730
    Mark Linneman
    Participant

    I discovered that Node Red UDP Input nodes treat their payloads as zero-terminated strings, even when you choose the “Buffer” option for the payload. In other words the data received via UDP/IP, and stored in the “buffer”, is treated as if it ends at the first instance of an byte with a value of zero. Therefore only “text” can be processed by these nodes. (The UDP Output node seems to have the same restriction.)

    Can you tell me whether the same is true for LoRa Input and LoRa Output nodes? The Input node has a payload choice of “UTF-8” or “Bytes”. I’m hoping that “Bytes” implies that the data bytes can take on any values, including zeros. I would try this myself, but I don’t yet have a LoRa device to talk to.

    My devices transmit and receive data that contains zeros, so I guess I’ll have to either modify the UDP node behavior or write my own. But I’m hoping the LoRa nodes will work as-is. I haven’t found any discussions in these forums on this subject. Thanks.

    #26731
    Jason Reiss
    Keymaster

    The payload is received by the lora-in node as a base64 string and transformed into a buffer within node-red.

    The lorawan payload will be presented in full as a buffer.

    lora-out node will do the reverse operation of converting a buffer to a base64 string.

    #26732
    Mark Linneman
    Participant

    Thanks. That’s good news. And now that you explained that, I retried the base64 encoding options on the UDP nodes and found that they work correctly. I could have sworn that I tried that before, and it stopped encoding at the first zero.

    Just one thing is unclear, though. The examples in the Node-RED “info” for the LoRa In and Out nodes clearly show regular text strings as the msg.payload, not base-64 encoded strings. Like this one for the LoRa Output node:

    “msg”: {
    “payload”: “Greetings from Conduit!”,
    “eui”: “00:11:22:33:44:55:66:88”,
    “ack”: false,
    “port”: 1
    }

    What causes the LoRa Input node to express the msg.payload in base-64 encoding in? Does it only do that when you choose the “bytes” payload option?

    Likewise, for the LoRa Output node, how do you indicate to the node that you are giving it “binary” data versus “text”? Thanks for the clarification.

    #26733
    Jason Reiss
    Keymaster

    The configuration of the lora-in node changes the output between a buffer or string. You must choose bytes to get a buffer from the node.

    The lora-out node will accept payload input as a buffer or a string and convert them to base64 to be passed to the network server. The type of “payload” field determines how the node will process the data.

    #26734
    Mark Linneman
    Participant

    That’s what I figured, but I thought I’d better ask since the “info” pages for these nodes surprisingly don’t mention any of this. Thanks, Jason.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.