Skip to content

Commit

Permalink
Fix logic for filtering and packet discovery.
Browse files Browse the repository at this point in the history
  • Loading branch information
bemasher committed Aug 28, 2014
1 parent b38a3d5 commit 4dcf600
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (rcvr *Receiver) Run() {
log.Fatal("Error reading samples: ", err)
}

pktFound := false
for _, pkt := range rcvr.d.Decode(block) {
scm, err := rcvr.p.Parse(NewDataFromBytes(pkt))
if err != nil {
Expand Down Expand Up @@ -143,15 +144,21 @@ func (rcvr *Receiver) Run() {
}
}

pktFound = true
if *single {
return
break
}
}

if *sampleFilename != os.DevNull {
_, err = sampleFile.Write(rcvr.d.iq)
if err != nil {
log.Fatal("Error writing raw samples to file:", err)
if pktFound {
if *sampleFilename != os.DevNull {
_, err = sampleFile.Write(rcvr.d.iq)
if err != nil {
log.Fatal("Error writing raw samples to file:", err)
}
}
if *single {
return
}
}
}
Expand Down

0 comments on commit 4dcf600

Please sign in to comment.