aboutsummaryrefslogtreecommitdiffstats
path: root/docs/concepts.rst
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-01-12 19:08:05 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-01-12 19:08:05 +0200
commit113bd7ee878ac2284c8c049fdb8dc2d2bd19f016 (patch)
treef38c617e54d763cee506c3314168bfb96a958f22 /docs/concepts.rst
parent0f6b615ae3395734ee9a1b35185540acad18c452 (diff)
Fixed issue 1 reported by Erik Rosen:
The size of non-callback bytes-fields was miscalculated, which caused all following fields in a message to contain garbage. Previous commit contains a testcase for this. This fix changes the generated message description. If your protocol uses bytes-fields, you should regenerate *.pb.c.
Diffstat (limited to 'docs/concepts.rst')
-rw-r--r--docs/concepts.rst5
1 files changed, 4 insertions, 1 deletions
diff --git a/docs/concepts.rst b/docs/concepts.rst
index f5e32ad..1d0fe08 100644
--- a/docs/concepts.rst
+++ b/docs/concepts.rst
@@ -158,7 +158,10 @@ required bytes data = 1 [(nanopb).max_size = 40];
| Person_data_t data;
=============================================================================== =======================
-The maximum lengths are checked in runtime. If string/bytes/array exceeds the allocated length, *pb_decode* will return false.
+The maximum lengths are checked in runtime. If string/bytes/array exceeds the allocated length, *pb_decode* will return false.
+
+Note: for the *bytes* datatype, the field length checking may not be exact.
+The compiler may add some padding to the *pb_bytes_t* structure, and the nanopb runtime doesn't know how much of the structure size is padding. Therefore it uses the whole length of the structure for storing data, which is not very smart but shouldn't cause problems. In practise, this means that if you specify *(nanopb).max_size=5* on a *bytes* field, you may be able to store 6 bytes there. For the *string* field type, the length limit is exact.
Field callbacks
===============