diff --git a/README.md b/README.md index 1ee866b3c..06224e8a7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ Available command-line flags are as follows: ``` Usage of rtlamr: - -decimation=1: integer decimation factor, keep every nth sample -duration=0s: time to run for, 0 for infinite, ex. 1h5m10s -filterid=: display only messages matching an id in a comma-separated list of ids. -filtertype=: display only messages matching a type in a comma-separated list of types. diff --git a/decode/decode.go b/decode/decode.go index 3d15d1dd0..d57ac8ed0 100644 --- a/decode/decode.go +++ b/decode/decode.go @@ -39,46 +39,7 @@ type PacketConfig struct { CenterFreq uint32 } -func (cfg PacketConfig) Decimate(decimation int) PacketConfig { - cfg.BlockSize /= decimation - cfg.BlockSize2 /= decimation - cfg.ChipLength /= decimation - cfg.SymbolLength /= decimation - cfg.SampleRate /= decimation - cfg.DataRate /= decimation - - cfg.PreambleLength /= decimation - cfg.PacketLength /= decimation - - cfg.BufferLength /= decimation - - return cfg -} - func (d Decoder) Log() { - if d.Decimation != 1 { - log.Printf("BlockSize: %d|%d\n", d.Cfg.BlockSize, d.DecCfg.BlockSize) - log.Println("CenterFreq:", d.Cfg.CenterFreq) - log.Printf("SampleRate: %d|%d\n", d.Cfg.SampleRate, d.DecCfg.SampleRate) - log.Printf("DataRate: %d|%d\n", d.Cfg.DataRate, d.DecCfg.DataRate) - log.Printf("ChipLength: %d|%d\n", d.Cfg.ChipLength, d.DecCfg.ChipLength) - log.Println("PreambleSymbols:", d.Cfg.PreambleSymbols) - log.Printf("PreambleLength: %d|%d\n", d.Cfg.PreambleLength, d.DecCfg.PreambleLength) - log.Println("PacketSymbols:", d.Cfg.PacketSymbols) - log.Printf("PacketLength: %d|%d\n", d.Cfg.PacketLength, d.DecCfg.PacketLength) - log.Println("Preamble:", d.Cfg.Preamble) - - if d.Cfg.ChipLength%d.Decimation != 0 { - log.Println("Warning: decimated symbol length is non-integral, sensitivity may be poor") - } - - if d.DecCfg.ChipLength < 3 { - log.Fatal("Error: illegal decimation factor, choose a smaller factor") - } - - return - } - log.Println("CenterFreq:", d.Cfg.CenterFreq) log.Println("SampleRate:", d.Cfg.SampleRate) log.Println("DataRate:", d.Cfg.DataRate) @@ -94,8 +55,7 @@ func (d Decoder) Log() { type Decoder struct { Cfg PacketConfig - Decimation int - DecCfg PacketConfig + DecCfg PacketConfig Signal []float64 Filtered []float64 @@ -113,7 +73,7 @@ type Decoder struct { } // Create a new decoder with the given packet configuration. -func NewDecoder(cfg PacketConfig, decimation int) (d Decoder) { +func NewDecoder(cfg PacketConfig) (d Decoder) { d.Cfg = cfg d.Cfg.SymbolLength = d.Cfg.ChipLength << 1 @@ -127,9 +87,6 @@ func NewDecoder(cfg PacketConfig, decimation int) (d Decoder) { d.Cfg.BufferLength = d.Cfg.PacketLength + d.Cfg.BlockSize - d.Decimation = decimation - d.DecCfg = d.Cfg.Decimate(d.Decimation) - // Allocate necessary buffers. d.Signal = make([]float64, d.DecCfg.BlockSize+d.DecCfg.SymbolLength) d.Filtered = make([]float64, d.DecCfg.BlockSize) diff --git a/flags.go b/flags.go index 46031201e..30eb50470 100644 --- a/flags.go +++ b/flags.go @@ -38,8 +38,6 @@ var msgType = flag.String("msgtype", "scm", "message type to receive: scm, scm+, var symbolLength = flag.Int("symbollength", 72, "symbol length in samples") -var decimation = flag.Int("decimation", 1, "integer decimation factor, keep every nth sample") - var timeLimit = flag.Duration("duration", 0, "time to run for, 0 for infinite, ex. 1h5m10s") var meterID MeterIDFilter var meterType MeterTypeFilter @@ -64,7 +62,6 @@ func RegisterFlags() { "samplefile": true, "msgtype": true, "symbollength": true, - "decimation": true, "duration": true, "filterid": true, "filtertype": true, diff --git a/idm/idm.go b/idm/idm.go index 073f1371b..4cc47d2f2 100644 --- a/idm/idm.go +++ b/idm/idm.go @@ -55,9 +55,9 @@ func (p *Parser) Cfg() *decode.PacketConfig { return &p.Decoder.Cfg } -func NewParser(chipLength, decimation int) (p parse.Parser) { +func NewParser(chipLength int) (p parse.Parser) { return &Parser{ - decode.NewDecoder(NewPacketConfig(chipLength), decimation), + decode.NewDecoder(NewPacketConfig(chipLength)), crc.NewCRC("CCITT", 0xFFFF, 0x1021, 0x1D0F), } } diff --git a/main.go b/main.go index 79d43d655..fe9b7b6e5 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ type Receiver struct { func (rcvr *Receiver) NewReceiver() { var err error - if rcvr.p, err = parse.NewParser(strings.ToLower(*msgType), *symbolLength, *decimation); err != nil { + if rcvr.p, err = parse.NewParser(strings.ToLower(*msgType), *symbolLength); err != nil { log.Fatal(err) } diff --git a/parse/parse.go b/parse/parse.go index 57958c50d..989086da2 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -20,7 +20,7 @@ var ( parsers = make(map[string]NewParserFunc) ) -type NewParserFunc func(symbolLength, decimation int) Parser +type NewParserFunc func(symbolLength int) Parser func Register(name string, parserFn NewParserFunc) { parserMutex.Lock() @@ -35,12 +35,12 @@ func Register(name string, parserFn NewParserFunc) { parsers[name] = parserFn } -func NewParser(name string, symbolLength, decimation int) (Parser, error) { +func NewParser(name string, symbolLength int) (Parser, error) { parserMutex.Lock() defer parserMutex.Unlock() if parserFn, exists := parsers[name]; exists { - return parserFn(symbolLength, decimation), nil + return parserFn(symbolLength), nil } else { return nil, fmt.Errorf("invalid message type: %q\n", name) } diff --git a/r900/r900.go b/r900/r900.go index ce2032b05..ca806058e 100644 --- a/r900/r900.go +++ b/r900/r900.go @@ -57,10 +57,10 @@ type Parser struct { quantized []byte } -func NewParser(chipLength, decimation int) parse.Parser { +func NewParser(chipLength int) parse.Parser { p := new(Parser) - p.Decoder = decode.NewDecoder(NewPacketConfig(chipLength), decimation) + p.Decoder = decode.NewDecoder(NewPacketConfig(chipLength)) // GF of order 32, polynomial 37, generator 2. p.field = gf.NewField(32, 37, 2) diff --git a/r900bcd/r900bcd.go b/r900bcd/r900bcd.go index ab8979ee3..e1726ce52 100644 --- a/r900bcd/r900bcd.go +++ b/r900bcd/r900bcd.go @@ -31,8 +31,8 @@ type Parser struct { parse.Parser } -func NewParser(ChipLength, decimation int) parse.Parser { - return Parser{r900.NewParser(ChipLength, decimation)} +func NewParser(ChipLength int) parse.Parser { + return Parser{r900.NewParser(ChipLength)} } // Parse messages using r900 parser and convert consumption from BCD to int. diff --git a/scm/scm.go b/scm/scm.go index 16ae6ec24..9cd62f781 100644 --- a/scm/scm.go +++ b/scm/scm.go @@ -46,9 +46,9 @@ type Parser struct { crc.CRC } -func NewParser(chipLength, decimation int) (p parse.Parser) { +func NewParser(chipLength int) (p parse.Parser) { return &Parser{ - decode.NewDecoder(NewPacketConfig(chipLength), decimation), + decode.NewDecoder(NewPacketConfig(chipLength)), crc.NewCRC("BCH", 0, 0x6F63, 0), } } diff --git a/scmplus/scmplus.go b/scmplus/scmplus.go index 57de4ada7..057efbd5b 100644 --- a/scmplus/scmplus.go +++ b/scmplus/scmplus.go @@ -55,9 +55,9 @@ func (p *Parser) Cfg() *decode.PacketConfig { return &p.Decoder.Cfg } -func NewParser(chipLength, decimation int) (p parse.Parser) { +func NewParser(chipLength int) (p parse.Parser) { return &Parser{ - decode.NewDecoder(NewPacketConfig(chipLength), decimation), + decode.NewDecoder(NewPacketConfig(chipLength)), crc.NewCRC("CCITT", 0xFFFF, 0x1021, 0x1D0F), } }