Read Vd right after TX

This commit is contained in:
Nonoo 2020-11-03 16:49:48 +01:00
parent 77296462a6
commit 7b384decc9
2 changed files with 9 additions and 18 deletions

View file

@ -6,7 +6,6 @@ import (
) )
const civAddress = 0xa4 const civAddress = 0xa4
const vdReadInterval = time.Minute
type civOperatingMode struct { type civOperatingMode struct {
name string name string
@ -63,7 +62,6 @@ var civBands = []civBand{
type civControlStruct struct { type civControlStruct struct {
st *serialStream st *serialStream
vdReadTimer *time.Timer
state struct { state struct {
freq uint freq uint
@ -211,7 +209,10 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
if d[1] == 1 { if d[1] == 1 {
s.state.ptt = true s.state.ptt = true
} else { } else {
if s.state.ptt { // PTT released?
s.state.ptt = false s.state.ptt = false
_ = s.getVd()
}
} }
case 1: case 1:
if d[1] == 2 { if d[1] == 2 {
@ -222,7 +223,10 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
_ = s.getTransmitStatus() _ = s.getTransmitStatus()
}) })
} else { } else {
if s.state.tune { // Tune finished?
s.state.tune = false s.state.tune = false
_ = s.getVd()
}
} }
} }
statusLog.reportPTT(s.state.ptt, s.state.tune) statusLog.reportPTT(s.state.ptt, s.state.tune)
@ -239,9 +243,6 @@ func (s *civControlStruct) decodeVd(d []byte) {
return return
} }
statusLog.reportVd(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16) statusLog.reportVd(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16)
s.vdReadTimer = time.AfterFunc(vdReadInterval, func() {
_ = s.getVd()
})
} }
} }
@ -480,10 +481,3 @@ func (s *civControlStruct) init(st *serialStream) error {
} }
return nil return nil
} }
func (s *civControlStruct) deinit() {
if s.vdReadTimer != nil {
s.vdReadTimer.Stop()
s.vdReadTimer = nil
}
}

View file

@ -270,9 +270,6 @@ func (s *serialStream) deinit() {
s.deinitNeededChan <- true s.deinitNeededChan <- true
<-s.deinitFinishedChan <-s.deinitFinishedChan
} }
if civControl != nil {
civControl.deinit()
}
civControl = nil civControl = nil
s.common.deinit() s.common.deinit()
s.rxSeqBuf.deinit() s.rxSeqBuf.deinit()