def to_bitfields(lens,byte_endianness=:little_endian, bits_little_endian=false)
    fields = []
    i = to_i(byte_endianness,bits_little_endian)
    for len in lens
      mask = (1<<len)-1
      fields << (i&mask)
      i >>= len
    end
    fields
  end
def to_bitfields(lens,byte_endianness=:little_endian, bits_little_endian=false)
    fields = []
    i = to_i(byte_endianness,bits_little_endian)
    for len in lens
      mask = (1<<len)-1
      fields << (i&mask)
      i >>= len
    end
    fields
  end
convert a byte string to separate fixed-width bit-fields as integers