Skip to content

Commit

Permalink
Remove cpuprofile flag, add version flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
bemasher committed Jan 20, 2016
1 parent dad7ae0 commit e8ea9d9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ Available command-line flags are as follows:

```
Usage of rtlamr:
-cpuprofile=: write cpu profile to this file
-decimation=1: integer decimation factor, keep every nth sample
-duration=0: 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.
-format=plain: format to write log messages in: plain, csv, json, xml or gob
-gobunsafe=false: allow gob output to stdout
-logfile=/dev/stdout: log statement dump file
-msgtype=scm: message type to receive: scm, idm or r900
-msgtype=scm: message type to receive: scm, idm, r900 or scm+
-quiet=false: suppress printing state information at startup
-samplefile=/dev/null: raw signal dump file
-single=false: one shot execution, if used with -filterid, will wait for exactly one packet from each meter id
-symbollength=72: symbol length in samples, see -help for valid lengths
-symbollength=72: symbol length in samples
-unique=false: suppress duplicate messages from each meter
-version=false: display build date and commit hash
rtltcp specific:
-agcmode=false: enable/disable rtl agc
Expand All @@ -53,6 +53,7 @@ rtltcp specific:
-tunergain=0: set tuner gain in dB
-tunergainmode=false: enable/disable tuner gain
-tunerxtalfreq=0: set tuner xtal frequency
```

Running the receiver is as simple as starting an `rtl_tcp` instance and then starting the receiver:
Expand Down
3 changes: 3 additions & 0 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ var gobUnsafe = flag.Bool("gobunsafe", false, "allow gob output to stdout")
var quiet = flag.Bool("quiet", false, "suppress printing state information at startup")
var single = flag.Bool("single", false, "one shot execution, if used with -filterid, will wait for exactly one packet from each meter id")

var version = flag.Bool("version", false, "display build date and commit hash")

func RegisterFlags() {
meterID = MeterIDFilter{make(UintMap)}
meterType = MeterTypeFilter{make(UintMap)}
Expand All @@ -80,6 +82,7 @@ func RegisterFlags() {
"single": true,
"cpuprofile": true,
"fastmag": true,
"version": true,
}

printDefaults := func(validFlags map[string]bool, inclusion bool) {
Expand Down
27 changes: 16 additions & 11 deletions recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"log"
"os"
"os/signal"
"runtime/pprof"
"strings"
"time"

Expand Down Expand Up @@ -193,13 +192,28 @@ func init() {
log.SetFlags(log.Lshortfile | log.Lmicroseconds)
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to this file")
var (
buildDate string // date -u '+%Y-%m-%d'
commitHash string // git rev-parse HEAD
)

func main() {
rcvr.RegisterFlags()
RegisterFlags()

flag.Parse()
if *version {
if buildDate == "" || commitHash == "" {
fmt.Println("Built from source.")
fmt.Println("Build Date: Unknown")
fmt.Println("Commit: Unknown")
} else {
fmt.Println("Build Date:", buildDate)
fmt.Println("Commit: ", commitHash)
}
os.Exit(0)
}

HandleFlags()

rcvr.NewReceiver()
Expand All @@ -208,14 +222,5 @@ func main() {
defer sampleFile.Close()
defer rcvr.Close()

if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}

rcvr.Run()
}

0 comments on commit e8ea9d9

Please sign in to comment.