Message Handling Functions
Main channel raw data send/receive functions.
This file contains functions to send and receive delimited messages reliably over a TCP socket. You should not need to use this in your programs, as high level abstractions for TRF messages are provided.
Functions
-
ssize_t trfMsgPack(TrfMsg__MessageWrapper *handle, uint32_t size, uint8_t *buf)
Pack message into a buffer to be sent.
- Parameters:
handle – Handle to message wrapper containing message to be sent
size – Size of provided buffer
buf – Buffer to store packed message
size_out – Output size of packed data in bytes
- Returns:
Number of bytes written, negative error code on failure.
-
ssize_t trfMsgPackProtobuf(ProtobufCMessage *message, uint32_t size, uint8_t *buf)
Pack message into a buffer to be sent. Generic version.
- Parameters:
handle – Handle to message wrapper containing message to be sent
size – Size of provided buffer
buf – Buffer to store packed message
size_out – Output size of packed data in bytes
- Returns:
Number of bytes written, negative error code on failure.
-
ssize_t trfMsgUnpack(TrfMsg__MessageWrapper **handle, uint32_t size, uint8_t *buf)
Unpack delimited message from buffer.
- Parameters:
handle – Handle to be set to unpacked message data
size – Length of the serialized message to be decoded
buf – Buffer containing message
- Returns:
0 on success, negative error code on failure
-
ssize_t trfMsgUnpackProtobuf(ProtobufCMessage **out, const ProtobufCMessageDescriptor *desc, size_t size, uint8_t *buf)
Unpack delimited message from buffer. Generic version.
- Parameters:
handle – Handle to be set to unpacked message data
size – Length of the serialized message to be decoded
buf – Buffer containing message
- Returns:
0 on success, negative error code on failure
-
static inline int32_t trfMsgGetPackedLength(uint8_t *buf)
-
static inline uint8_t *trfMsgGetPayload(uint8_t *buf)