diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-21 10:30:06 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-21 10:30:06 +0200 |
commit | 68a5c65f9b0e1df30e9cef490d9b218b2f21f90d (patch) | |
tree | 804ec0edc0769764b0a090703cf784c2ac7a6f5c /proto/puzbusv1.h | |
parent | db8906d54cd9afbc57f0b40a0d618335c552f704 (diff) |
clean up puzbusv1 API
Diffstat (limited to 'proto/puzbusv1.h')
-rw-r--r-- | proto/puzbusv1.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/proto/puzbusv1.h b/proto/puzbusv1.h index 95130c9..0985b2b 100644 --- a/proto/puzbusv1.h +++ b/proto/puzbusv1.h @@ -7,10 +7,12 @@ extern "C" { #endif +/** \brief Puzzle bus message (v1) */ struct pb_msg { - uint16_t addr; - char* data; - size_t length; + uint16_t addr; //!< I^2^C address + char * data; //!< message content + size_t length; //!< message size + size_t _rdata; //!< \private remaining bytes to read until message is complete }; /** @@ -32,7 +34,7 @@ struct pb_msg { * the message is not fully parsed. This variable must be `free()`d by the * caller after each complete message to prevent memory leaks. */ -int pb_read(struct pb_msg* target, char* buf, size_t buf_sz); +int pb_read(struct pb_msg * target, const char * buf, size_t buf_sz); /** * \brief reset the remaining message data counter @@ -42,7 +44,7 @@ int pb_read(struct pb_msg* target, char* buf, size_t buf_sz); * before reading a TCP frame's data to mitigate any synchronization issues * arising from earlier corrupt or otherwise malformed messages. */ -void pb_read_reset(); +void pb_read_reset(struct pb_msg * target); /** * \brief Allocate and write a msgpack-formatted message to \p buf @@ -60,7 +62,7 @@ void pb_read_reset(); * * \note the pointer stored in \p buf must be `free()`d by the caller afterwards */ -bool pb_write(struct pb_msg* target, char** buf, size_t* buf_sz); +bool pb_write(const struct pb_msg * target, char ** buf, size_t * buf_sz); #ifdef __cplusplus } |