30#ifndef PROTOCORE_SUNSPEC_H
31#define PROTOCORE_SUNSPEC_H
35#if PROTOCORE_ENABLE_SUNSPEC
39#define SUNSPEC_MARKER 0x53756E53u
40#define SUNSPEC_END_MODEL 0xFFFFu
41#define SUNSPEC_COMMON_MODEL 1
55proto_bool protocore_sunspec_check_marker(
const uint8_t *regs,
size_t len);
58proto_bool protocore_sunspec_begin(
const uint8_t *regs,
size_t len,
size_t *offset);
64proto_bool protocore_sunspec_next_model(
const uint8_t *regs,
size_t len,
size_t *offset, SunSpecModel *out);
67uint16_t protocore_sunspec_u16(
const uint8_t *body,
size_t reg);
68int16_t protocore_sunspec_i16(
const uint8_t *body,
size_t reg);
69uint32_t protocore_sunspec_u32(
const uint8_t *body,
size_t reg);
70int32_t protocore_sunspec_i32(
const uint8_t *body,
size_t reg);
76proto_bool protocore_sunspec_string(
const uint8_t *body,
size_t reg,
size_t nregs,
char *out,
size_t out_cap);
89void protocore_sunspec_writer_init(SunSpecWriter *w, uint8_t *buf,
size_t cap);
90proto_bool protocore_sunspec_write_marker(SunSpecWriter *w);
91proto_bool protocore_sunspec_write_model_header(SunSpecWriter *w, uint16_t
id, uint16_t length);
92proto_bool protocore_sunspec_write_u16(SunSpecWriter *w, uint16_t v);
93proto_bool protocore_sunspec_write_i16(SunSpecWriter *w, int16_t v);
94proto_bool protocore_sunspec_write_u32(SunSpecWriter *w, uint32_t v);
95proto_bool protocore_sunspec_write_i32(SunSpecWriter *w, int32_t v);
96proto_bool protocore_sunspec_write_string(SunSpecWriter *w,
const char *s,
98proto_bool protocore_sunspec_write_end_model(SunSpecWriter *w);
99size_t protocore_sunspec_writer_finish(SunSpecWriter *w);
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS