pdcomm_modbus_buffer_copy
Function
Copies a JSON reply buffer as UTF-8 without a terminator.
int32_t pdcomm_modbus_buffer_copy(pdcomm_modbus_handle buffer, uint8_t *output, size_t capacity, size_t *size)Pass a null output and zero capacity to query the size, then allocate and copy. The buffer is immutable and stays valid until it is released.
Parameters
| Name | Description |
|---|---|
buffer | Buffer handle returned by pdcomm_modbus_call(). |
output | Destination, or null when capacity is zero. |
capacity | Size of output in bytes. |
size | Receives the buffer size in bytes; must not be null. |
Returns
#PDCOMM_MODBUS_OK, #PDCOMM_MODBUS_BUFFER_TOO_SMALL when capacity is smaller than the buffer (the output is unchanged), #PDCOMM_MODBUS_INVALID_INPUT, or #PDCOMM_MODBUS_INVALID_HANDLE when buffer is not a live buffer handle.
Notes
- Thread-safe; a buffer can be copied from any thread.