Skip to content

Commit

Permalink
Revert change to Quantize invocation.
Browse files Browse the repository at this point in the history
This is the 2nd time this has bitten me. For reasons I can't be bothered
to investigate much further the R900 decoder requires that preamble indexes
be offset by a full symbol length.

Reverting the previous commit that ignored a symbol length's worth of
samples when quantizing fixed this in the R900 decoder and broke everything
else because the R900 decoder still depends on this buffer for preamble
detection and does it's own signal processing for everything else. It's
preamble begins with 0's and can randomly pick up preambles without any
signal present for the first symbol. The rest of the protocols, not so much.
  • Loading branch information
bemasher committed Oct 2, 2016
1 parent 57926fc commit b2dba49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (d Decoder) Decode(input []byte) []int {
d.Filter(d.Signal, d.Filtered)

// Perform bit-decision on new block.
Quantize(d.Filtered[d.DecCfg.SymbolLength:], d.Quantized[d.DecCfg.PacketLength:])
Quantize(d.Filtered, d.Quantized[d.DecCfg.PacketLength:])

// Pack the quantized signal into slices for searching.
d.Transpose(d.Quantized)
Expand Down Expand Up @@ -281,13 +281,13 @@ func (d *Decoder) Transpose(input []byte) {
// buffer.
func (d *Decoder) Search() (indexes []int) {
for symbolOffset, slice := range d.slices {
offset := 0
lastIdx := 0
idx := 0
for {
idx = d.preambleFinder.next(slice[offset:])
idx = d.preambleFinder.next(slice[lastIdx:])
if idx != -1 {
indexes = append(indexes, (offset+idx)*d.DecCfg.SymbolLength+symbolOffset)
offset += idx + 1
indexes = append(indexes, (lastIdx+idx)*d.DecCfg.SymbolLength+symbolOffset)
lastIdx += idx + 1
} else {
break
}
Expand Down
2 changes: 1 addition & 1 deletion r900/r900.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (p Parser) Parse(indices []int) (msgs []parse.Message) {
break
}

payloadIdx := preambleIdx + preambleLength
payloadIdx := preambleIdx + preambleLength - p.Dec().DecCfg.SymbolLength
var digits string
for idx := 0; idx < PayloadSymbols*4*cfg.ChipLength; idx += chipLength * 4 {
qIdx := payloadIdx + idx
Expand Down

0 comments on commit b2dba49

Please sign in to comment.