mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
process rigctld response only if needed
This commit is contained in:
parent
d572772df3
commit
281731d890
|
@ -101,7 +101,7 @@ class radio:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
self.connected = False
|
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,
|
"""Send a command to the connected rotctld instance,
|
||||||
and return the return value.
|
and return the return value.
|
||||||
|
|
||||||
|
@ -122,7 +122,12 @@ class radio:
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# 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)
|
return self.connection.recv(16)
|
||||||
|
else:
|
||||||
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"[RIGCTLD] No command response!",
|
"[RIGCTLD] No command response!",
|
||||||
|
@ -146,7 +151,7 @@ class radio:
|
||||||
def get_mode(self):
|
def get_mode(self):
|
||||||
""" """
|
""" """
|
||||||
try:
|
try:
|
||||||
data = self.send_command(b"m")
|
data = self.send_command(b"m", True)
|
||||||
data = data.split(b"\n")
|
data = data.split(b"\n")
|
||||||
data = data[0].decode("utf-8")
|
data = data[0].decode("utf-8")
|
||||||
if 'RPRT' not in data:
|
if 'RPRT' not in data:
|
||||||
|
@ -159,7 +164,7 @@ class radio:
|
||||||
def get_bandwidth(self):
|
def get_bandwidth(self):
|
||||||
""" """
|
""" """
|
||||||
try:
|
try:
|
||||||
data = self.send_command(b"m")
|
data = self.send_command(b"m", True)
|
||||||
data = data.split(b"\n")
|
data = data.split(b"\n")
|
||||||
data = data[1].decode("utf-8")
|
data = data[1].decode("utf-8")
|
||||||
|
|
||||||
|
@ -172,7 +177,7 @@ class radio:
|
||||||
def get_frequency(self):
|
def get_frequency(self):
|
||||||
""" """
|
""" """
|
||||||
try:
|
try:
|
||||||
data = self.send_command(b"f")
|
data = self.send_command(b"f", True)
|
||||||
data = data.decode("utf-8")
|
data = data.decode("utf-8")
|
||||||
if 'RPRT' not in data:
|
if 'RPRT' not in data:
|
||||||
self.frequency = data
|
self.frequency = data
|
||||||
|
@ -184,7 +189,7 @@ class radio:
|
||||||
def get_ptt(self):
|
def get_ptt(self):
|
||||||
""" """
|
""" """
|
||||||
try:
|
try:
|
||||||
return self.send_command(b"t")
|
return self.send_command(b"t", True)
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -199,9 +204,9 @@ class radio:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if state:
|
if state:
|
||||||
self.send_command(b"T 1")
|
self.send_command(b"T 1", False)
|
||||||
else:
|
else:
|
||||||
self.send_command(b"T 0")
|
self.send_command(b"T 0", False)
|
||||||
return state
|
return state
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue