2019-05-16 11:55 AM
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
2019-05-16 01:14 PM
Fixed format? Mostly numbers? Use a binary format.
JW
2019-05-16 02:16 PM
Yes mostly numbers with decimal point, other characters are ',' and ';'
What do you suggest?
Thank you
2019-05-16 02:41 PM
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
2019-05-16 10:21 PM
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).