Serial / Ethernet Reader
Overview
This prefab reads raw data from a Serial (UART) port / Ethernet channel and emits it downstream as BYTES packets. Because the incoming data arrives as a continuous stream with no built-in message boundaries, the prefab provides four packet reading modes that define where one packet ends and the next begins:
LISTEN— collect everything, flush after a fixed number of bytes.FIXED— packets start with a magic word and have a fixed payload size.DYNAMIC— packets start with a magic word and carry their own length field.END— packets are delimited by a start magic word and an end magic word.
How it Works
The reader runs in cycles. Each cycle it reads bytes from the Serial (UART) port / Ethernet channel, assembles them into a packet according to the selected mode, and sends the completed packet on the output port. If a packet cannot be completed within timeout(ms), the cycle ends: in LISTEN mode any bytes collected so far are flushed as a packet, while in the other modes the partial packet is discarded and the reader resynchronizes on the next magic word.
If the optional trigger input is connected, the reader waits for a message on it before starting each cycle. This lets you gate reading behind another node (for example, read one packet only after a command has been written to the device). If trigger is not connected, the reader runs continuously.
A single packet can be at most 256 KiB (262,144 bytes). Anything larger is discarded with a warning.
FIXED, DYNAMIC, and END all frame packets around a magic word, so those constants are grouped into a single Magic Word section in the node’s configuration panel: start (the byte sequence marking the start of every packet) is shown for FIXED, DYNAMIC, and END, while end (the byte sequence marking the end of every packet) is shown for END only.
Modes
Each mode below includes a public example workflow. To try one in your own company, click Copy JSON to Clipboard in the top-left corner of the embedded workflow, then paste it under Blueprints > Import.
LISTEN
Passively collects every byte that arrives on the Serial (UART) port / Ethernet channel. A packet is emitted once max(bytes) bytes have been collected, or when timeout(ms) elapses — in which case whatever has been collected so far (if anything) is flushed as a packet. This is the mode to use when the device’s protocol has no framing, or when you just want to observe the raw stream.
Constants
| Constant | Type | Description |
|---|---|---|
mode | Option | Required. Set to LISTEN. |
timeout(ms) | NUMBER | Required. Maximum time in milliseconds to collect bytes before flushing whatever has been collected so far. |
max(bytes) | NUMBER | Required. Number of bytes to collect before emitting a packet. Must be greater than 0. |
Example
The example below collects raw data and uploads it to the cloud every 1,000 ms or whenever 1,024 bytes have accumulated. It also shows a second variant gated by a trigger input, which reads only once per Cloud Trigger signal.
| Constant | Value |
|---|---|
mode | LISTEN |
timeout(ms) | 1000 |
max(bytes) | 1024 |
Serial
FIXED
For protocols where every packet is the same size. The reader scans the stream for start, then reads exactly payload(bytes) more bytes.
Emitted packet: start + payload(bytes) bytes.
Constants
| Constant | Type | Description |
|---|---|---|
mode | Option | Required. Set to FIXED. |
timeout(ms) | NUMBER | Required. Maximum time in milliseconds to complete one packet. On timeout, the partial packet is discarded and the reader resynchronizes on the next magic word. |
start | Byte list | Required. The byte sequence that marks the start of every packet. Written as a list of numbers separated by commas or whitespace; square brackets are optional. Both decimal and hexadecimal (0x) notation are accepted — 0xAA, 0x55 is the same as [170, 85] or 170 85. |
payload(bytes) | NUMBER | Required. Number of payload bytes to read after the magic word, counted separately from the magic word itself. Must be greater than 0, and must be at least as many bytes as start. |
Example
The example below scans for the magic word 0xAA 0xBB, then reads a 5-byte payload and uploads the combined frame to the cloud. The read cycle is gated behind a trigger input, so one packet is read per incoming trigger signal rather than continuously. If the magic word is not found within the timeout, the data is dropped.
| Constant | Value |
|---|---|
mode | FIXED |
timeout(ms) | 1000 |
start | 0xAA 0xBB |
payload(bytes) | 5 |
Serial
DYNAMIC
For length-prefixed protocols, where each packet declares its own payload size in a header field. The reader:
- Scans the stream for
start. - Buffers
offsetbytes (the gap between the magic word and the length field, if any). These bytes are not interpreted — they’re just carried through to the output. - Reads a
length(bytes)-wide integer, decoded according toendian:big— the first byte read is the most significant byte (standard network byte order).little— the first byte read is the least significant byte.
- Adds
adjustmentto the decoded value, and reads that many payload bytes.
Emitted packet: start + offset gap bytes + length field + payload. The header bytes are all included in the output, so downstream nodes (like Bytes to Value) see the full frame.
If the adjusted length is 0, the packet is emitted with just the header. If it is negative, or the total packet would exceed 256 KiB, the packet is discarded with a warning and the reader resynchronizes on the next magic word.
Constants
| Constant | Type | Description |
|---|---|---|
mode | Option | Required. Set to DYNAMIC. |
timeout(ms) | NUMBER | Required. Maximum time in milliseconds to complete one packet. On timeout, the partial packet is discarded and the reader resynchronizes on the next magic word. |
start | Byte list | Required. The byte sequence that marks the start of every packet. Written as a list of numbers separated by commas or whitespace; square brackets are optional. Both decimal and hexadecimal (0x) notation are accepted — 0xAA, 0x55 is the same as [170, 85] or 170 85. |
offset | NUMBER | Number of bytes between the end of the magic word and the start of the length field. Defaults to 0 (length field comes immediately after the magic word). |
endian | Option | Required. Byte order used to decode the length field: big or little. big reads the first byte of the field as the most significant byte (e.g. 0x01 0x2C → 300); little reads the first byte as the least significant byte (e.g. 0x01 0x2C → 0x2C01 = 11265). |
length(bytes) | Option | Required. Width of the length field in bytes: 1, 2, 3, or 4. |
adjustment | NUMBER | A signed correction added to the decoded length value — useful when the length field excludes trailing bytes such as a CRC. Defaults to 0. |
Worked example. Suppose start: 0xAA 0xBB, offset: 1, length(bytes): 2, endian: big, adjustment: 2, and the following bytes arrive on the wire:
AA BB 00 01 2C 11 22 33 ...AA BBmatchesstart.00is the 1offsetbyte — buffered as-is, not interpreted.01 2Cis the 2-byte length field. Decoded as big-endian, the first byte (01) is most significant, giving0x012C=300.adjustmentof2is added:300 + 2 = 302payload bytes to read.- The reader then reads the next 302 bytes (starting from
11 22 33 ...) and emitsAA BB 00 01 2C+ those 302 bytes as one packet.
Had endian been little instead, the same 01 2C field would decode with 01 as the least significant byte: 0x2C01 = 11265, giving a very different (and in most protocols, wrong) payload length — so it’s important that endian matches the byte order the device actually sends.
Example
The example below scans for the magic word 0xAA 0xBB, buffers a 1-byte offset, decodes a 2-byte big-endian length field (length(bytes): 2), adds an adjustment of 2, and uploads the full frame to the cloud. As with the FIXED example, the read cycle is gated behind a trigger input, so one packet is read per trigger signal.
| Constant | Value |
|---|---|
mode | DYNAMIC |
timeout(ms) | 1000 |
start | 0xAA 0xBB |
offset | 1 |
endian | big |
length(bytes) | 2 |
adjustment | 2 |
Serial
END
For protocols that terminate packets with a marker (for example, ASCII protocols ending in \r\n). The reader scans for start, then collects everything up to and including end.
Emitted packet: start + body + end.
Constants
| Constant | Type | Description |
|---|---|---|
mode | Option | Required. Set to END. |
timeout(ms) | NUMBER | Required. Maximum time in milliseconds to complete one packet. On timeout, the partial packet is discarded and the reader resynchronizes on the next magic word. |
start | Byte list | Required. The byte sequence that marks the start of every packet. Written as a list of numbers separated by commas or whitespace; square brackets are optional. Both decimal and hexadecimal (0x) notation are accepted — 0xAA, 0x55 is the same as [170, 85] or 170 85. |
end | Byte list | Required. The byte sequence that marks the end of every packet. Uses the same format as start. |
Example
The example below scans for the start magic word 0xAA 0xBB, accumulates every byte until the end magic word 0xCC 0xDD appears, and uploads the full frame to the cloud. This example is likewise gated behind a trigger input, so one packet is captured per trigger signal.
| Constant | Value |
|---|---|
mode | END |
timeout(ms) | 1000 |
start | 0xAA 0xBB |
end | 0xCC 0xDD |
Serial
Ports
- Inputs:
trigger(optional):ANY- Optional. When connected, the reader waits for a message here before starting each read cycle. The message content is ignored — any data type works. - Outputs:
output:BYTES- Sends one message per completed packet.
Peripherals
serial/ethernet- The Serial (UART) port or Ethernet channel to read from. The node itself only picks the channel; the bus’s own parameters (baud rate, data bits, IP address, connect port, etc.) are set once per channel in the Blueprint Editor’s Global Peripheral Configuration panel — see UART / Serial or Ethernet there for the exact fields.
The channel here is the UART channel defined on the device itself: 0 is UART Channel 0 and 1 is UART Channel 1, as configured in Hardware settings. Ethernet has only channel 0, and has no pins to assign — it runs over the onboard W5500 module. If the UART channel you pick has no pins assigned in Hardware settings, the reader starts but never receives any bytes.