diff --git a/tnc/data_handler.py b/tnc/data_handler.py index 44552860..1be4d544 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -1534,7 +1534,7 @@ class DATA: + "]>>?<<[" + 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, ) diff --git a/tnc/modem.py b/tnc/modem.py index f13abfda..388938f7 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -975,7 +975,10 @@ class RF: rms = int(np.sqrt(np.max(d ** 2))) static.AUDIO_DBFS = 20 * np.log10(rms / 32768) 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 rms_counter = 0 diff --git a/tnc/rigctld.py b/tnc/rigctld.py index deff4f45..e4ab069a 100644 --- a/tnc/rigctld.py +++ b/tnc/rigctld.py @@ -4,6 +4,7 @@ # # modified and adjusted to FreeDATA needs by DJ2LS +import contextlib import socket import time import structlog @@ -124,10 +125,7 @@ class radio: 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) - else: - return True + return self.connection.recv(16) if expect_answer else True except Exception: self.log.warning( "[RIGCTLD] No command response!", @@ -171,11 +169,9 @@ class radio: data = data.split(b"\n") data = data[1].decode("utf-8") - if 'RPRT' not in data: - try: + if 'RPRT' not in data and data not in ['']: + with contextlib.suppress(ValueError): self.bandwidth = int(data) - except ValueError: - pass return self.bandwidth except Exception: return self.bandwidth @@ -186,11 +182,11 @@ class radio: data = self.send_command(b"f", True) data = data.decode("utf-8") if 'RPRT' not in data and data not in [0, '0', '']: - try: - self.frequency = int(data) - except ValueError: - pass - + with contextlib.suppress(ValueError): + data = int(data) + # make sure we have a frequency and not bandwidth + if data >= 10000: + self.frequency = data return self.frequency except Exception: return self.frequency