Example #1
0
func TestNewRandSCM(t *testing.T) {
	bch := crc.NewCRC("BCH", 0, 0x6F63, 0)

	for i := 0; i < 512; i++ {
		scm, err := NewRandSCM()
		if err != nil {
			t.Fatal(err)
		}

		checksum := bch.Checksum(scm[2:])
		if checksum != 0 {
			t.Fatalf("Failed checksum: %04X\n", checksum)
		}
	}
}
Example #2
0
File: gen.go Project: thess/rtlamr
func NewRandSCM() (pkt []byte, err error) {
	bch := crc.NewCRC("BCH", 0, 0x6F63, 0)

	pkt = make([]byte, 12)
	_, err = rand.Read(pkt)
	if err != nil {
		return nil, err
	}

	pkt[0] = 0xF9
	pkt[1] = 0x53
	pkt[2] &= 0x07

	checksum := bch.Checksum(pkt[2:10])
	pkt[10] = uint8(checksum >> 8)
	pkt[11] = uint8(checksum & 0xFF)

	return
}
Example #3
0
func NewParser(symbolLength, decimation int, fastMag bool) (p Parser) {
	p.Decoder = decode.NewDecoder(NewPacketConfig(symbolLength), decimation, fastMag)
	p.CRC = crc.NewCRC("BCH", 0, 0x6F63, 0)
	return
}
Example #4
0
func NewParser(symbolLength int, fastMag bool) (p Parser) {
	p.Decoder = decode.NewDecoder(NewPacketConfig(symbolLength), fastMag)
	p.CRC = crc.NewCRC("CCITT", 0xFFFF, 0x1021, 0x1D0F)
	return
}
Example #5
0
File: scm.go Project: thess/rtlamr
func NewParser(chipLength, decimation int) (p parse.Parser) {
	return &Parser{
		decode.NewDecoder(NewPacketConfig(chipLength), decimation),
		crc.NewCRC("BCH", 0, 0x6F63, 0),
	}
}
Example #6
0
func NewParser(symbolLength, decimation int) (p parse.Parser) {
	return &Parser{
		decode.NewDecoder(NewPacketConfig(symbolLength), decimation),
		crc.NewCRC("CCITT", 0xFFFF, 0x1021, 0x1D0F),
	}
}
Example #7
0
func NewParser(symbolLength, decimation int) (p Parser) {
	p.Decoder = decode.NewDecoder(NewPacketConfig(symbolLength), decimation)
	p.CRC = crc.NewCRC("CCITT", 0xFFFF, 0x1021, 0x1D0F)
	return
}