cancel
Showing results for 
Search instead for 
Did you mean: 

String compression for UART on STM32F7

MMand.9
Associate

Hi, I'm working on a project in which i need to send strings through UART

My throughput is limited because i'm working with Xbees, so i want to compress my ascii strings (that are long 1024 bytes and with simple structure because they are in csv format) before sending them. I thought about using zlib or similar things, can you implement this on stm? If yes, which is the best alternative?

Thank you

4 REPLIES 4

Fixed format? Mostly numbers? Use a binary format.

JW

Yes mostly numbers with decimal point, other characters are ',' and ';'

What do you suggest?

Thank you

As I've said - transmit the numbers in binary. They started as binary, didn't they, you then converted them to ASCII. Skip that step, or in other words, move that step to the receiver side.

If you insist on compressing ASCII - which will probably never be that efficient - I'd make some stats over some relatively big number of those strings, and create a fixed Huffman table and then use that for compression/decompression, as 1024 chars IMO can't be compressed efficiently with the off-the-shelf routines - try yourself zipping them up with common zip programs.

JW

That would be ten different number characters, plus a few formatting and control characters. So, 4 bit used instead of 8.

You could try your own one-by-one substitution, and transfer two characters in a byte (one in each nibble).