process rigctld response only if needed

This commit is contained in:
DJ2LS 2022-12-27 18:17:12 +01:00
parent d6df3007db
commit 76522db082
3 changed files with 14 additions and 15 deletions

View file

@ -1534,7 +1534,7 @@ class DATA:
+ "]>>?<<[" + "]>>?<<["
+ str(self.dxcallsign, "UTF-8") + str(self.dxcallsign, "UTF-8")
+ "]", + "]",
a=str(attempt + 1) + "/" + str(self.session_connect_max_retries), # Adjust for 0-based for user display a=f"{str(attempt + 1)}/{str(self.session_connect_max_retries)}",
state=static.ARQ_SESSION_STATE, state=static.ARQ_SESSION_STATE,
) )

View file

@ -975,7 +975,10 @@ class RF:
rms = int(np.sqrt(np.max(d ** 2))) rms = int(np.sqrt(np.max(d ** 2)))
static.AUDIO_DBFS = 20 * np.log10(rms / 32768) static.AUDIO_DBFS = 20 * np.log10(rms / 32768)
except Exception as e: except Exception as e:
self.log.warning(f"[MDM] fft calculation error - please check your audio setup", e=e) self.log.warning(
"[MDM] fft calculation error - please check your audio setup",
e=e,
)
static.AUDIO_DBFS = -100 static.AUDIO_DBFS = -100
rms_counter = 0 rms_counter = 0

View file

@ -4,6 +4,7 @@
# #
# modified and adjusted to FreeDATA needs by DJ2LS # modified and adjusted to FreeDATA needs by DJ2LS
import contextlib
import socket import socket
import time import time
import structlog import structlog
@ -124,10 +125,7 @@ class radio:
try: try:
# recv seems to be blocking so in case of ptt we dont need the response # recv seems to be blocking so in case of ptt we dont need the response
# maybe this speeds things up and avoids blocking states # maybe this speeds things up and avoids blocking states
if expect_answer: return self.connection.recv(16) if expect_answer else True
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!",
@ -171,11 +169,9 @@ class radio:
data = data.split(b"\n") data = data.split(b"\n")
data = data[1].decode("utf-8") data = data[1].decode("utf-8")
if 'RPRT' not in data: if 'RPRT' not in data and data not in ['']:
try: with contextlib.suppress(ValueError):
self.bandwidth = int(data) self.bandwidth = int(data)
except ValueError:
pass
return self.bandwidth return self.bandwidth
except Exception: except Exception:
return self.bandwidth return self.bandwidth
@ -186,11 +182,11 @@ class radio:
data = self.send_command(b"f", True) data = self.send_command(b"f", True)
data = data.decode("utf-8") data = data.decode("utf-8")
if 'RPRT' not in data and data not in [0, '0', '']: if 'RPRT' not in data and data not in [0, '0', '']:
try: with contextlib.suppress(ValueError):
self.frequency = int(data) data = int(data)
except ValueError: # make sure we have a frequency and not bandwidth
pass if data >= 10000:
self.frequency = data
return self.frequency return self.frequency
except Exception: except Exception:
return self.frequency return self.frequency