PB_ENCODE_ARRAYS_UNPACKED

60 views
Skip to first unread message

Dietmar

unread,
Nov 24, 2023, 1:38:48 AM11/24/23
to nanopb
Hi,

I'm trying to encode an array in the unpacked format. It contains 192 sfixed64 elements, pb_get_encoded_size() calculates 1728 Bytes length of the encoded message.

When calling pb_encode_ex(...,PB_ENCODE_DELIMITED), there's the error message "stream full" in file pb_encode.c, line 746. This if statement checks (stream->bytes_written + size > stream->max_size). The actual values are 2 + 1728 > 1728.

I saw that this does not happen when using pb_encode() instead of pb_encode_ex().

Does anybody have an idea?

Thanks.
Best regards,
Dietmar

Petteri Aimonen

unread,
Nov 24, 2023, 2:09:40 AM11/24/23
to nan...@googlegroups.com
Hi,

> pb_get_encoded_size() calculates 1728 Bytes length of the encoded message.
>
> When calling pb_encode_ex(...,PB_ENCODE_DELIMITED), there's the error
> message "stream full" in file pb_encode.c, line 746. This if statement
> checks (stream->bytes_written + size > stream->max_size). The actual values
> are 2 + 1728 > 1728.

PB_ENCODE_DELIMITED prepends the message length to the message in varint format.
For the length 1728, encoding the length takes 2 bytes.

--
Petteri

Dietmar

unread,
Nov 24, 2023, 2:36:18 AM11/24/23
to nanopb
Hi Petteri,

your answer followed incredibly fast, thank you.

now I've a well understood base and I'll try to get my larger messages working as well.

Thanks.
Best regards,
Dietmar
Reply all
Reply to author
Forward
0 new messages