[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.pack with bit resolution
- From: Francisco Olarte <folarte@...>
- Date: Wed, 16 Oct 2019 12:24:58 +0200
On Wed, Oct 16, 2019 at 11:17 AM bil til <flyer31@googlemail.com> wrote:
> If you want to transfer data over such lines, it is very important to pack
> numbers very efficiently into communication buffers, and "very" here
> ultimately requires "bit-efficiently".
> For such bit and byte packing, we could do our own formatting, but it would
> be very nice, if the format string could be interchanged with other devices
> / other people, and then would describe the buffer contents unique, at least
> in "lua world".
Byte packer and bit packers are different beasts, and I've done both.
You'll have to rewrite all pack and make it mucho more complex.
I think your use case will be better served by a different "bitpack"
module. This is easier to do in C, specially in modern ( 32 bit ) CPUs
( I've done it in z80 assembly and it was a PITA, and in 32 bit C
which was way easier ). Portability shouldn't be too hard, you could
easily do it in ANSI. And a dedicated module let's you add things like
precompiled format strings and freedom to put things like golomb
coding, ascii ( or teletype ) strings which can be useful if you have
fast cpu ( relative to link speed, against a 9600 link current 32 bits
microcontrollers are fast ).
Francisco Olarte.