From 281731d890bb0762b9f0d0aeb7206b4ba2914dce Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Tue, 27 Dec 2022 17:48:06 +0100 Subject: [PATCH] process rigctld response only if needed --- tnc/rigctld.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tnc/rigctld.py b/tnc/rigctld.py index 6a9fd928..c802eab9 100644 --- a/tnc/rigctld.py +++ b/tnc/rigctld.py @@ -101,7 +101,7 @@ class radio: self.sock.close() self.connected = False - def send_command(self, command) -> bytes: + def send_command(self, command, expect_answer) -> bytes: """Send a command to the connected rotctld instance, and return the return value. @@ -122,7 +122,12 @@ class radio: self.connected = False try: - return self.connection.recv(16) + # recv seems to be blocking so in case of ptt we dont need the response + # maybe this speeds things up and avoids blocking states + if expect_answer: + return self.connection.recv(16) + else: + return True except Exception: self.log.warning( "[RIGCTLD] No command response!", @@ -146,7 +151,7 @@ class radio: def get_mode(self): """ """ try: - data = self.send_command(b"m") + data = self.send_command(b"m", True) data = data.split(b"\n") data = data[0].decode("utf-8") if 'RPRT' not in data: @@ -159,7 +164,7 @@ class radio: def get_bandwidth(self): """ """ try: - data = self.send_command(b"m") + data = self.send_command(b"m", True) data = data.split(b"\n") data = data[1].decode("utf-8") @@ -172,7 +177,7 @@ class radio: def get_frequency(self): """ """ try: - data = self.send_command(b"f") + data = self.send_command(b"f", True) data = data.decode("utf-8") if 'RPRT' not in data: self.frequency = data @@ -184,7 +189,7 @@ class radio: def get_ptt(self): """ """ try: - return self.send_command(b"t") + return self.send_command(b"t", True) except Exception: return False @@ -199,9 +204,9 @@ class radio: """ try: if state: - self.send_command(b"T 1") + self.send_command(b"T 1", False) else: - self.send_command(b"T 0") + self.send_command(b"T 0", False) return state except Exception: return False