Revert "Add SWR display" as it always reads 0 from the transceiver

This reverts commit 54f48b23c7.
This commit is contained in:
Nonoo 2020-11-01 16:48:56 +01:00
parent 54f48b23c7
commit ffaa5df63c
4 changed files with 9 additions and 68 deletions

View file

@ -118,8 +118,6 @@ is up) with the following info:
- `state`: RX/TX/TUNE depending on the PTT status - `state`: RX/TX/TUNE depending on the PTT status
- `freq`: operating frequency in MHz, mode (LSB/USB/FM...), active filter - `freq`: operating frequency in MHz, mode (LSB/USB/FM...), active filter
- `txpwr`: current transmit power setting in percent - `txpwr`: current transmit power setting in percent
- `swr`: current SWR, this is automatically read after a TX unless disabled
with the `-w` command line argument
- `audiomon`: current status of the audio monitor (see the *Hotkeys* section - `audiomon`: current status of the audio monitor (see the *Hotkeys* section
in this README for more information about this feature) in this README for more information about this feature)

View file

@ -16,7 +16,6 @@ var runCmd string
var disableReRunCmd bool var disableReRunCmd bool
var runCmdOnSerialPortCreated string var runCmdOnSerialPortCreated string
var statusLogInterval time.Duration var statusLogInterval time.Duration
var disableAutoSWRRead bool
func parseArgs() { func parseArgs() {
h := getopt.BoolLong("help", 'h', "display help") h := getopt.BoolLong("help", 'h', "display help")
@ -28,7 +27,6 @@ func parseArgs() {
e := getopt.BoolLong("disable-rerun", 'e', "Disable re-execing the cmd on TCP serial port disconnect") e := getopt.BoolLong("disable-rerun", 'e', "Disable re-execing the cmd on TCP serial port disconnect")
o := getopt.StringLong("run-serial", 'o', "socat /tmp/kappanhang-IC-705.pty /tmp/vmware.pty", "Exec cmd when virtual serial port is created, set to - to disable") o := getopt.StringLong("run-serial", 'o', "socat /tmp/kappanhang-IC-705.pty /tmp/vmware.pty", "Exec cmd when virtual serial port is created, set to - to disable")
i := getopt.Uint16Long("log-interval", 'i', 100, "Status bar/log interval in milliseconds") i := getopt.Uint16Long("log-interval", 'i', 100, "Status bar/log interval in milliseconds")
w := getopt.BoolLong("disable-auto-swr-read", 'w', "Disable auto SWR read after PTT off")
getopt.Parse() getopt.Parse()
@ -46,5 +44,4 @@ func parseArgs() {
disableReRunCmd = *e disableReRunCmd = *e
runCmdOnSerialPortCreated = *o runCmdOnSerialPortCreated = *o
statusLogInterval = time.Duration(*i) * time.Millisecond statusLogInterval = time.Duration(*i) * time.Millisecond
disableAutoSWRRead = *w
} }

View file

@ -98,8 +98,6 @@ func (s *civControlStruct) decode(d []byte) {
s.decodeDataMode(payload) s.decodeDataMode(payload)
case 0x14: case 0x14:
s.decodePower(payload) s.decodePower(payload)
case 0x15:
s.decodeSWR(payload)
case 0x1c: case 0x1c:
s.decodeTransmitStatus(payload) s.decodeTransmitStatus(payload)
} }
@ -193,20 +191,6 @@ func (s *civControlStruct) decodePower(d []byte) {
statusLog.reportTxPower(s.state.pwrPercent) statusLog.reportTxPower(s.state.pwrPercent)
} }
func (s *civControlStruct) decodeSWR(d []byte) {
if len(d) < 3 || d[0] != 0x12 {
return
}
v := uint16(d[1])<<8 | uint16(d[2])
var swr float64
if v > 0x120 {
swr = -1
} else {
swr = (float64(v) / 0x120) * 3
}
statusLog.reportSWR(swr)
}
func (s *civControlStruct) decodeTransmitStatus(d []byte) { func (s *civControlStruct) decodeTransmitStatus(d []byte) {
if len(d) < 2 { if len(d) < 2 {
return return
@ -218,9 +202,6 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
s.state.ptt = true s.state.ptt = true
} else { } else {
s.state.ptt = false s.state.ptt = false
if !disableAutoSWRRead {
_ = s.getSWR()
}
} }
case 1: case 1:
if d[1] == 2 { if d[1] == 2 {
@ -231,9 +212,6 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
_ = s.getTransmitStatus() _ = s.getTransmitStatus()
}) })
} else { } else {
if s.state.tune {
_ = s.getSWR()
}
s.state.tune = false s.state.tune = false
} }
} }
@ -423,10 +401,6 @@ func (s *civControlStruct) getTransmitStatus() error {
return s.st.send([]byte{254, 254, civAddress, 224, 0x1c, 1, 253}) return s.st.send([]byte{254, 254, civAddress, 224, 0x1c, 1, 253})
} }
func (s *civControlStruct) getSWR() error {
return s.st.send([]byte{254, 254, civAddress, 224, 0x15, 0x12, 253})
}
func (s *civControlStruct) init(st *serialStream) error { func (s *civControlStruct) init(st *serialStream) error {
s.st = st s.st = st
@ -446,8 +420,5 @@ func (s *civControlStruct) init(st *serialStream) error {
if err := s.getTransmitStatus(); err != nil { if err := s.getTransmitStatus(); err != nil {
return err return err
} }
if err := s.getSWR(); err != nil {
return err
}
return nil return nil
} }

View file

@ -20,7 +20,6 @@ type statusLogData struct {
dataMode string dataMode string
filter string filter string
txPowerStr string txPowerStr string
swrStr string
startTime time.Time startTime time.Time
rttStr string rttStr string
@ -37,8 +36,8 @@ type statusLogStruct struct {
mutex sync.Mutex mutex sync.Mutex
preGenerated struct { preGenerated struct {
warningColor *color.Color retransmitsColor *color.Color
errorColor *color.Color lostColor *color.Color
stateStr struct { stateStr struct {
unknown string unknown string
@ -160,26 +159,6 @@ func (s *statusLogStruct) reportTxPower(percent int) {
s.data.txPowerStr = fmt.Sprint(percent, "%") s.data.txPowerStr = fmt.Sprint(percent, "%")
} }
func (s *statusLogStruct) reportSWR(swr float64) {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.data == nil {
return
}
if swr < 0 {
s.data.swrStr = s.preGenerated.errorColor.Sprint(" 3.0+ ")
} else {
if swr <= 2 {
s.data.swrStr = fmt.Sprintf("%.1f", swr)
} else if swr < 3 {
s.data.swrStr = s.preGenerated.warningColor.Sprintf(" %.1f ", swr)
} else {
s.data.swrStr = s.preGenerated.errorColor.Sprintf(" %.1f ", swr)
}
}
}
func (s *statusLogStruct) clearInternal() { func (s *statusLogStruct) clearInternal() {
fmt.Printf("%c[2K", 27) fmt.Printf("%c[2K", 27)
} }
@ -224,21 +203,17 @@ func (s *statusLogStruct) update() {
if s.data.txPowerStr != "" { if s.data.txPowerStr != "" {
txPowerStr = " txpwr " + s.data.txPowerStr txPowerStr = " txpwr " + s.data.txPowerStr
} }
var swrStr string
if s.data.swrStr != "" {
swrStr = " swr " + s.data.swrStr
}
s.data.line1 = fmt.Sprint("state ", s.data.stateStr, " freq: ", fmt.Sprintf("%.6f", float64(s.data.frequency)/1000000), s.data.line1 = fmt.Sprint("state ", s.data.stateStr, " freq: ", fmt.Sprintf("%.6f", float64(s.data.frequency)/1000000),
modeStr, filterStr, txPowerStr, swrStr, " audio ", s.data.audioStateStr) modeStr, filterStr, txPowerStr, " audio ", s.data.audioStateStr)
up, down, lost, retransmits := netstat.get() up, down, lost, retransmits := netstat.get()
lostStr := "0" lostStr := "0"
if lost > 0 { if lost > 0 {
lostStr = s.preGenerated.errorColor.Sprint(" ", lost, " ") lostStr = s.preGenerated.lostColor.Sprint(" ", lost, " ")
} }
retransmitsStr := "0" retransmitsStr := "0"
if retransmits > 0 { if retransmits > 0 {
retransmitsStr = s.preGenerated.warningColor.Sprint(" ", retransmits, " ") retransmitsStr = s.preGenerated.retransmitsColor.Sprint(" ", retransmits, " ")
} }
s.data.line2 = fmt.Sprint("up ", s.padLeft(fmt.Sprint(time.Since(s.data.startTime).Round(time.Second)), 6), s.data.line2 = fmt.Sprint("up ", s.padLeft(fmt.Sprint(time.Since(s.data.startTime).Round(time.Second)), 6),
@ -346,8 +321,8 @@ func (s *statusLogStruct) initIfNeeded() {
s.preGenerated.stateStr.tune = c.Sprint(" TUNE ") s.preGenerated.stateStr.tune = c.Sprint(" TUNE ")
s.preGenerated.audioStateStr.rec = c.Sprint(" REC ") s.preGenerated.audioStateStr.rec = c.Sprint(" REC ")
s.preGenerated.warningColor = color.New(color.FgHiWhite) s.preGenerated.retransmitsColor = color.New(color.FgHiWhite)
s.preGenerated.warningColor.Add(color.BgYellow) s.preGenerated.retransmitsColor.Add(color.BgYellow)
s.preGenerated.errorColor = color.New(color.FgHiWhite) s.preGenerated.lostColor = color.New(color.FgHiWhite)
s.preGenerated.errorColor.Add(color.BgRed) s.preGenerated.lostColor.Add(color.BgRed)
} }