Sunday, 17 May 2015

Variable-length FreeRTOS queue messages

One of the fundamental mechanisms for transferring information from interrupts and between FreeRTOS tasks is the queue. FreeRTOS queues are reliable and versatile yet have the constraint that queued items must be a fixed size. This is so FreeRTOS can honour real-time guarantees without heap management or other complications. In the shipping lanes of my software, the queues are the ships carrying standard-size containers. Continue Reading

Sunday, 3 May 2015

Space-efficient data representation

A project I am working on uses embedded systems that push packets over satellite links. It turns out that sending data over the satellite network is very expensive (billed per byte), and reducing the number of bytes per message has real cost savings.

Whenever I need to serialise data in an embedded system, I reach for nano-pb. It’s an excellent, compact implementation of Google’s Protocol Buffers. Using an existing library has a couple of advantages. Firstly, I don’t have to write and debug one myself and secondly, serialisation is a two-way process (something has to deserialise the data after all) and there are Protocol Buffers implementations for all kinds of platforms and languages.

In this case though, the protocol buffers wire format is just too verbose, and after extensively searching for something suitable, I’ve reluctantly had to stitch together my own. When developing any library of this kind, my design goals are to produce a small, well-tested core, and then layer the API as an abstraction over the core.
Continue Reading