bdc

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(bytes []byte) ([]int, error)

Parse will interpret the input bytes as a BDC 4-bit number stream.

Types

type BitSlice

type BitSlice struct {
	// contains filtered or unexported fields
}

BitSlice is an array of bits. This allows us to slice and re-interpret the bits, regardless of how they got to us.

For AIS, we get data in 6-bit bytes, but we need to slice them up without regard to any particular alignment.

This is a memory hog (it's a slice of bools), and not very fast, but it's going to be a good place to start optimizing from, once it's all working.

func NewBitSlice

func NewBitSlice() BitSlice

NewBitSlice will allocate a new BitSlice.

func NewBitSliceFromBytes

func NewBitSliceFromBytes(data []byte) (*BitSlice, error)

NewBitSliceFromBytes will allocate a new BitSlice, and fill it with the bytes provided.

func (*BitSlice) Append

func (bv *BitSlice) Append(bit bool)

Append a single bit to the bit slice.

func (*BitSlice) AppendByte

func (bv *BitSlice) AppendByte(b byte, length uint)

AppendByte will append a byte to the list, MSB first.

func (*BitSlice) AppendBytes

func (bv *BitSlice) AppendBytes(data []byte, length uint)

AppendBytes will append a slice of bytes.

func (*BitSlice) BigEndianUint

func (bv *BitSlice) BigEndianUint() uint

BigEndianUint will Read the bit slice as a uint. This assumes the Nth index is the MSB.

func (*BitSlice) Length

func (bv *BitSlice) Length() int

Length will return the number of bits in this bit vector.

func (*BitSlice) Slice

func (bv *BitSlice) Slice(from, length uint) *BitSlice

Slice the bit slice from bit offset `from`, for `length` bits. That slice is returned as another BitSlice, which can be interpreted from there.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL