6#include "stackusage.pb.h"
16#define MAX_STACK_ENTRIES 1024
47 SettingsGroup msg = SettingsGroup_init_zero;
50 msg.has_settings =
true;
52 strcpy(msg.settings.name,
"abcd");
53 msg.settings.en =
true;
54 msg.settings.has_begin =
true;
55 msg.settings.begin.label = 1234;
56 msg.settings.begin.properties_count = 1;
57 msg.settings.begin.properties[0].which_field = Property_DeviceA_Mode_tag;
58 msg.settings.begin.properties[0].field.DeviceA_Mode = 2;
60 status =
pb_encode(&stream, SettingsGroup_fields, &msg);
69 SettingsGroup msg = SettingsGroup_init_zero;
72 status =
pb_decode(&stream, SettingsGroup_fields, &msg);
74 assert(msg.settings.begin.properties[0].field.DeviceA_Mode == 2);
79 int stack_encode, stack_decode;
90 printf(
"%d %d\n", stack_encode, stack_decode);
91 fprintf(
stderr,
"Stack usage: encode %d bytes, decode %d bytes\n",
92 stack_encode, stack_decode);
MOSAPI char * strcpy(char *__restrict dest, const char *__restrict src)
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t msglen)
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
static uint32_t g_stackbuf[1024]
int end_stack_measuring()
static volatile uint32_t * g_stackptr
static uint8_t g_msgbuf[256]
void start_stack_measuring()
#define MAX_STACK_ENTRIES