Hi,

I’m currently spending some time writing a new SPI. One where not everything is 
mixed up together, as we currently have it.

I’m particularly trying to create a new ReadBufferByteBased and 
WriteBufferByteBased, which correclty supports a pluggable system for providing 
custom endianess and encodings.

Nuw the core of my current implementation is a method:
byte[] readBits(int numBits, boolean alignToByteBoundary);

This simply returns a byteArray with all the bits required to be read.

I’m a bit torn about the Endainess and the Encoding as both are sort of tightly 
coupled.
However I finally decided to have them separated. Now I have a 
ByteOrderBigEndian, and ByteOrderLittleEndian.

In paralell I’ll have „Encoding“ implementations, that should take care of the 
real decoding of the byte data.
Now I’m currently a bit unsure about how I should handle LittleEndian (Encoding 
in general).

Should I apply the endianess first and then read the bits, or the other way 
around?

Little example … I’m at bit 4 of the current byte and now want to read 16 bits 
Little Endian.
So I rearange the bytes first and then read the bits, or do I read the bits 
first and then reverse them.
In one case the order in the resulting byte array will be reversed in the 
middle of the bytes, in the other case they will be reversed within the output 
bytes.

Any ideas?

Chris


Reply via email to