mlot / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Add support for smaller data size (8-16 bit ints) #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Add support for 16bit ints

As you probably know, almost all µC use 16 bits for adc conversion, when I 
want to send a table with 100 measurements I need to make some kind of "magic" 
to fit 2 measurements into one 32int field or just send a message with 16bit 
values as 32 ones, and generate a lot of unneeded traffic.

Original issue reported on code.google.com by cszawisza on 11 Mar 2014 at 7:46

GoogleCodeExporter commented 9 years ago
The protobuf standard encodes int32_t (and others except fixed32_t) as varints. 
This means that they only take as much space as the value requires:

Values 0-127:      1 byte
Values 128-16383:  2 bytes
etc.

So you are not generating any unneeded traffic. Only local RAM usage is a bit 
higher, but if you have a large uint16_t array, you can encode it using 
callbacks.

Original comment by Petteri.Aimonen on 11 Mar 2014 at 2:26