Hello,
Thanks for your work on NanoPb. I really like it!
I am struggling with realizing a protokoll via SPI. Nanopb is on the SPI slave side, the master will periodically poll the slave and read "one buffer". A double buffer system reserves one to read/write from and one rx/tx set is connected o the SPI via DMA.
Before writing to the buffer a mutex needs to be taken, so that if the master does read the spi buffer, the switch over does only happen after nanopb is done writing. Which can be implemented in a custom callback as far as I can see.
Now to the point, with this mechanism incomplete pb messages could be in a buffer given to the spi, since nanopb will make multiple calls to the stream callback if I understand correctly. Does anyone see a way to solve that on the nanopb size? Probably wrapping pb_encode_ex()?
Otherwise I will probably need to transfer a small header in each spi packet indicating the payload length in addition to the length delimited pb messages. And assemble the messages back in the host.