diff --git a/README.md b/README.md index 84ae82e..6419e8b 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,6 @@ is up) with the following info: - `state`: RX/TX/TUNE depending on the PTT status - `freq`: operating frequency in MHz, mode (LSB/USB/FM...), active filter - `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 in this README for more information about this feature) diff --git a/args.go b/args.go index 03b3a74..1ab72e5 100644 --- a/args.go +++ b/args.go @@ -16,7 +16,6 @@ var runCmd string var disableReRunCmd bool var runCmdOnSerialPortCreated string var statusLogInterval time.Duration -var disableAutoSWRRead bool func parseArgs() { 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") 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") - w := getopt.BoolLong("disable-auto-swr-read", 'w', "Disable auto SWR read after PTT off") getopt.Parse() @@ -46,5 +44,4 @@ func parseArgs() { disableReRunCmd = *e runCmdOnSerialPortCreated = *o statusLogInterval = time.Duration(*i) * time.Millisecond - disableAutoSWRRead = *w } diff --git a/civcontrol.go b/civcontrol.go index 9c4160a..bf3860e 100644 --- a/civcontrol.go +++ b/civcontrol.go @@ -98,8 +98,6 @@ func (s *civControlStruct) decode(d []byte) { s.decodeDataMode(payload) case 0x14: s.decodePower(payload) - case 0x15: - s.decodeSWR(payload) case 0x1c: s.decodeTransmitStatus(payload) } @@ -193,20 +191,6 @@ func (s *civControlStruct) decodePower(d []byte) { 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) { if len(d) < 2 { return @@ -218,9 +202,6 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) { s.state.ptt = true } else { s.state.ptt = false - if !disableAutoSWRRead { - _ = s.getSWR() - } } case 1: if d[1] == 2 { @@ -231,9 +212,6 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) { _ = s.getTransmitStatus() }) } else { - if s.state.tune { - _ = s.getSWR() - } 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}) } -func (s *civControlStruct) getSWR() error { - return s.st.send([]byte{254, 254, civAddress, 224, 0x15, 0x12, 253}) -} - func (s *civControlStruct) init(st *serialStream) error { s.st = st @@ -446,8 +420,5 @@ func (s *civControlStruct) init(st *serialStream) error { if err := s.getTransmitStatus(); err != nil { return err } - if err := s.getSWR(); err != nil { - return err - } return nil } diff --git a/statuslog.go b/statuslog.go index c177f88..83893d3 100644 --- a/statuslog.go +++ b/statuslog.go @@ -20,7 +20,6 @@ type statusLogData struct { dataMode string filter string txPowerStr string - swrStr string startTime time.Time rttStr string @@ -37,8 +36,8 @@ type statusLogStruct struct { mutex sync.Mutex preGenerated struct { - warningColor *color.Color - errorColor *color.Color + retransmitsColor *color.Color + lostColor *color.Color stateStr struct { unknown string @@ -160,26 +159,6 @@ func (s *statusLogStruct) reportTxPower(percent int) { 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() { fmt.Printf("%c[2K", 27) } @@ -224,21 +203,17 @@ func (s *statusLogStruct) update() { if 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), - modeStr, filterStr, txPowerStr, swrStr, " audio ", s.data.audioStateStr) + modeStr, filterStr, txPowerStr, " audio ", s.data.audioStateStr) up, down, lost, retransmits := netstat.get() lostStr := "0" if lost > 0 { - lostStr = s.preGenerated.errorColor.Sprint(" ", lost, " ") + lostStr = s.preGenerated.lostColor.Sprint(" ", lost, " ") } retransmitsStr := "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), @@ -346,8 +321,8 @@ func (s *statusLogStruct) initIfNeeded() { s.preGenerated.stateStr.tune = c.Sprint(" TUNE ") s.preGenerated.audioStateStr.rec = c.Sprint(" REC ") - s.preGenerated.warningColor = color.New(color.FgHiWhite) - s.preGenerated.warningColor.Add(color.BgYellow) - s.preGenerated.errorColor = color.New(color.FgHiWhite) - s.preGenerated.errorColor.Add(color.BgRed) + s.preGenerated.retransmitsColor = color.New(color.FgHiWhite) + s.preGenerated.retransmitsColor.Add(color.BgYellow) + s.preGenerated.lostColor = color.New(color.FgHiWhite) + s.preGenerated.lostColor.Add(color.BgRed) }