From c52b1a2774edb0c7829d377ae4f21b2ae75c907a Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Wed, 22 Jan 2025 20:25:47 +0100 Subject: [PATCH] rigcontrol: Fix PTT STATE 3 experiment Ref la5nta/pat#184 --- rigcontrol/hamlib/experimental_ptt.go | 12 ++++-------- rigcontrol/hamlib/rigctld.go | 10 ++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/rigcontrol/hamlib/experimental_ptt.go b/rigcontrol/hamlib/experimental_ptt.go index 4215f71..3a1088e 100644 --- a/rigcontrol/hamlib/experimental_ptt.go +++ b/rigcontrol/hamlib/experimental_ptt.go @@ -7,14 +7,10 @@ import ( ) // Experimental PTT STATE 3 (https://github.com/la5nta/pat/issues/184) - -func init() { - if experimentalPTT3Enabled() { +var experimentalPTT3Enabled = func() bool { + ok, _ := strconv.ParseBool(os.Getenv("EXPERIMENTAL_HAMLIB_PTT3")) + if ok { log.Println("Experimental PTT3 enabled (https://github.com/la5nta/pat/issues/184)") } -} - -func experimentalPTT3Enabled() bool { - ok, _ := strconv.ParseBool(os.Getenv("EXPERIMENTAL_HAMLIB_PTT3")) return ok -} +}() diff --git a/rigcontrol/hamlib/rigctld.go b/rigcontrol/hamlib/rigctld.go index 9eafc2e..62675bc 100644 --- a/rigcontrol/hamlib/rigctld.go +++ b/rigcontrol/hamlib/rigctld.go @@ -165,13 +165,11 @@ func (v *tcpVFO) GetPTT() (bool, error) { // Enable (or disable) PTT on this VFO. func (v *tcpVFO) SetPTT(on bool) error { bInt := 0 - if on == true { + if on { bInt = 1 - } - - // Experimental PTT STATE 3 (https://github.com/la5nta/pat/issues/184) - if experimentalPTT3Enabled() { - bInt = 3 + if experimentalPTT3Enabled { + bInt = 3 + } } _, err := v.cmd(`\set_ptt %d`, bInt)