mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 10:04:33 +02:00
hopefully fixed rigctld fetching
This commit is contained in:
parent
cf06bbffea
commit
8ccff438d0
|
@ -2,7 +2,7 @@
|
||||||
"name": "FreeDATA",
|
"name": "FreeDATA",
|
||||||
"description": "FreeDATA Client application for connecting to FreeDATA server",
|
"description": "FreeDATA Client application for connecting to FreeDATA server",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.13.6-alpha",
|
"version": "0.13.6-alpha.1",
|
||||||
"main": "dist-electron/main/index.js",
|
"main": "dist-electron/main/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|
|
@ -76,7 +76,11 @@ class radio:
|
||||||
self.connection.sendall(command.encode('utf-8') + b"\n")
|
self.connection.sendall(command.encode('utf-8') + b"\n")
|
||||||
response = self.connection.recv(1024)
|
response = self.connection.recv(1024)
|
||||||
self.await_response.set()
|
self.await_response.set()
|
||||||
return response.decode('utf-8').strip()
|
stripped_result = response.decode('utf-8').strip()
|
||||||
|
if 'RPRT' in stripped_result:
|
||||||
|
return None
|
||||||
|
return stripped_result
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.log.warning(f"[RIGCTLD] Error sending command [{command}] to rigctld: {err}")
|
self.log.warning(f"[RIGCTLD] Error sending command [{command}] to rigctld: {err}")
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
@ -189,24 +193,70 @@ class radio:
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
if self.connected:
|
if self.connected:
|
||||||
self.parameters['frequency'] = self.send_command('f')
|
self.get_frequency()
|
||||||
response = self.send_command(
|
self.get_mode_bandwidth()
|
||||||
'm').strip() # Get the mode/bandwidth response and remove leading/trailing spaces
|
self.get_alc()
|
||||||
try:
|
self.get_strength()
|
||||||
mode, bandwidth = response.split('\n', 1) # Split the response into mode and bandwidth
|
self.get_rf()
|
||||||
except ValueError:
|
|
||||||
|
return self.parameters
|
||||||
|
|
||||||
|
def get_frequency(self):
|
||||||
|
try:
|
||||||
|
frequency_response = self.send_command('f')
|
||||||
|
self.parameters['frequency'] = frequency_response if frequency_response is not None else 'err'
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f"Error getting frequency: {e}")
|
||||||
|
self.parameters['frequency'] = 'err'
|
||||||
|
|
||||||
|
def get_mode_bandwidth(self):
|
||||||
|
try:
|
||||||
|
response = self.send_command('m')
|
||||||
|
if response is not None:
|
||||||
|
response = response.strip()
|
||||||
|
mode, bandwidth = response.split('\n', 1)
|
||||||
|
else:
|
||||||
mode = 'err'
|
mode = 'err'
|
||||||
bandwidth = 'err'
|
bandwidth = 'err'
|
||||||
|
except ValueError:
|
||||||
|
mode = 'err'
|
||||||
|
bandwidth = 'err'
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f"Error getting mode and bandwidth: {e}")
|
||||||
|
mode = 'err'
|
||||||
|
bandwidth = 'err'
|
||||||
|
finally:
|
||||||
self.parameters['mode'] = mode
|
self.parameters['mode'] = mode
|
||||||
self.parameters['bandwidth'] = bandwidth
|
self.parameters['bandwidth'] = bandwidth
|
||||||
|
|
||||||
self.parameters['alc'] = self.send_command('l ALC')
|
def get_alc(self):
|
||||||
self.parameters['strength'] = self.send_command('l STRENGTH')
|
try:
|
||||||
self.parameters['rf'] = int(float(self.send_command('l RFPOWER')) * 100) # RF, RFPOWER
|
alc_response = self.send_command('l ALC')
|
||||||
|
self.parameters['alc'] = alc_response if alc_response is not None else 'err'
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f"Error getting ALC: {e}")
|
||||||
|
self.parameters['alc'] = 'err'
|
||||||
|
|
||||||
"""Return the latest fetched parameters."""
|
def get_strength(self):
|
||||||
return self.parameters
|
try:
|
||||||
|
strength_response = self.send_command('l STRENGTH')
|
||||||
|
self.parameters['strength'] = strength_response if strength_response is not None else 'err'
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f"Error getting strength: {e}")
|
||||||
|
self.parameters['strength'] = 'err'
|
||||||
|
|
||||||
|
def get_rf(self):
|
||||||
|
try:
|
||||||
|
rf_response = self.send_command('l RFPOWER')
|
||||||
|
if rf_response is not None:
|
||||||
|
self.parameters['rf'] = int(float(rf_response) * 100)
|
||||||
|
else:
|
||||||
|
self.parameters['rf'] = 'err'
|
||||||
|
except ValueError:
|
||||||
|
self.parameters['rf'] = 'err'
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(f"Error getting RF power: {e}")
|
||||||
|
self.parameters['rf'] = 'err'
|
||||||
|
|
||||||
def start_service(self):
|
def start_service(self):
|
||||||
binary_name = "rigctld"
|
binary_name = "rigctld"
|
||||||
|
|
|
@ -29,7 +29,7 @@ app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
CORS(app, resources={r"/*": {"origins": "*"}})
|
CORS(app, resources={r"/*": {"origins": "*"}})
|
||||||
sock = Sock(app)
|
sock = Sock(app)
|
||||||
MODEM_VERSION = "0.13.6-alpha"
|
MODEM_VERSION = "0.13.6-alpha.1"
|
||||||
|
|
||||||
# set config file to use
|
# set config file to use
|
||||||
def set_config():
|
def set_config():
|
||||||
|
|
Loading…
Reference in a new issue