From 7afd5a675f1ecf43bfb5f9ee695e87a3f4d519ad Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 1 Aug 2024 01:31:18 -0700 Subject: [PATCH] Update radio.py --- modules/radio.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/radio.py b/modules/radio.py index 9616bff..444f1ff 100644 --- a/modules/radio.py +++ b/modules/radio.py @@ -16,15 +16,19 @@ def get_hamlib(msg="f"): print(f"\nSystem: Error connecting to rigctld: {e}") return ERROR_FETCHING_DATA - build_msg = f"{msg}\n" - MESSAGE = bytes(build_msg, "utf-8") - rigControlSocket.sendall(MESSAGE) - # Look for the response - data = rigControlSocket.recv(16) - rigControlSocket.close() - # strip newline and return - data = data.replace(b'\n',b'') - return data.decode("utf-8").rstrip() + try: + build_msg = f"{msg}\n" + MESSAGE = bytes(build_msg, "utf-8") + rigControlSocket.sendall(MESSAGE) + # Look for the response + data = rigControlSocket.recv(16) + rigControlSocket.close() + # strip newline and return + data = data.replace(b'\n',b'') + return data.decode("utf-8").rstrip() + except Exception as e: + print(f"\nSystem: Error fetching data from rigctld: {e}") + return ERROR_FETCHING_DATA def get_freq_common_name(freq): freq = int(freq)