Compression for embedded / no_std

Hi, I have a data stream of f32s in a no_std context from the output of an AHRS fusion algorithm with accelerometer and gyroscope. I am going to transmit this data over cellular and I have relatively much RAM and CPU left over compared to transmit speed. So I would like to compress this data before transmitting it.

Ideally the compression should be lossless, but it doesn't absolutely have to be. So far the only no_std alternative I have found is:

but there must be other options out there! Does anyone have any recommendations. I'd be open to try porting or compiling a C library, if there isn't that much available in Rust yet.

-- gaute

2 Likes

Without having any specific tip, maybe one of the search results: crates.io
Or even better on lib.rs

I forgot to specify that it needs to be no_std. Of those results I haven't found any that are std free, and also preferably alloc free.

The compression crate seems to have a alloc feature flag

This search seems to return interesting results.

Which one? It seems to have a flag for turning off std, but not alloc.

This one also seems to have an option for no_std, but not alloc free. Maybe I should give alloc a go..

It could be that data compression without allocations is just very complicated ^^
I guess you could try to reimplement one of the alloc ones to use a fixed size buffer as memory (compression could then fail), but at that point having an allocator might just be the easier solution. If you are very concerned about stability and prevent oom errors, maybe creating a PR to use the try_ versions for allocations (rather new stable rust feature) could help here.

Yes, I think it will be worth trying with alloc here, was hoping to avoid that. Think compression would be a big enough gain for this project. I am guessing that the allocation sizes will be pretty stable on fixed input buffers. Probably not a bigger problem than stack overflows anyway.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.