pack_bytes()
Generates a sequence of bytes by arranging element data.
Generates a sequence of bytes by arranging element data.
pack_bytes
takes a begin()
,end()
iterator of the container class as a parameter and writes the data specified by the following parameters to the container as a sequence of bytes.
The data given for the variable argument parameters are as follows
Data Type | Number of Bytes | Description |
---|---|---|
| 1 | |
| 2 | Stored in big-endian order |
| 4 | Stored in big-endian order |
| N | Fixed-length array of type |
| N | A pair of an array of type |
The pack_bytes
takes a container object as a parameter and writes the data specified by the subsequent parameters as a sequence of bytes into the container. It is appended to the end by the container's .push_back()
method.
The data given as variable argument parameters is shown below.
Data Type | Number of Bytes | Description |
---|---|---|
| 1 | |
| 2 | Stored in big-endian order |
| 4 | Stored in big-endian order |
| N | Fixed-length array of type |
| N | A pair of an array of type |
|
| smplbuf<> |
Example
In this example, each attribute and payload of the received packet is re-stored in a separate buffer buf
.
Background
To simplify the description of byte arrays of type uint8_t
used in the generation of data payloads and extraction of data in non-volatile packets.
The above is the simplest description, but byte arrays can be generated using Byte array utils as follows.
最終更新