Skip to main content

from-buffer

Syntax

- from-buffer: spec

The spec is a string that can include:

  • offset: Byte offset into the buffer (default 0).
  • type: One of uint8, int8, uint16, int16, uint32, int32, uint64, int64, float32, float64, double, string. Default is uint8.
  • order: Byte order be (big-endian) or le (little-endian). Default is be.
  • length: For string type only, the number of bytes to read. If omitted or zero, the entire buffer from the offset to the end is returned as a UTF-8 string.

Examples: uint16, offset=4 type=float32 order=le, type=string length=20, type=string (entire buffer).

Description

The from-buffer operation reads a value from a binary buffer at the given offset and type, and forwards it. Input must be a buffer (for example from to-buffer or a device that supplies buffers). For string type, when length is not specified or is zero, the whole buffer from the offset to the end is output as a string.

Examples

  first-word:
- source: binary-tag
- from-buffer: uint16
payload-string:
- source: binary-tag
- from-buffer: offset=8 type=string