Merge pull request #653 from DJ2LS/dev-arq

arq adjustments
This commit is contained in:
Mashintime 2024-02-18 15:37:04 -05:00 committed by GitHub
commit 0213e538fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 32 deletions

View file

@ -54,7 +54,6 @@ const defaultConfig = {
enable_protocol: false,
},
MODEM: {
enable_fft: false,
enable_fsk: false,
enable_low_bandwidth_mode: false,
respond_to_cq: false,

View file

@ -96,9 +96,7 @@ class ARQSessionIRS(arq_session.ARQSession):
self.log(f"Waiting {timeout} seconds...")
if not self.event_frame_received.wait(timeout):
self.log("Timeout waiting for ISS. Session failed.")
self.session_ended = time.time()
self.set_state(IRS_State.FAILED)
self.event_manager.send_arq_session_finished(False, self.id, self.dxcall, False, self.state.name, statistics=self.calculate_session_statistics())
self.transmission_failed()
def launch_transmit_and_wait(self, frame, timeout, mode):
thread_wait = threading.Thread(target = self.transmit_and_wait,
@ -208,11 +206,7 @@ class ARQSessionIRS(arq_session.ARQSession):
flag_checksum=False)
self.transmit_frame(ack, mode=FREEDV_MODE.signalling)
self.log("CRC fail at the end of transmission!")
self.session_ended = time.time()
self.set_state(IRS_State.FAILED)
self.event_manager.send_arq_session_finished(
False, self.id, self.dxcall, False, self.state.name, statistics=self.calculate_session_statistics())
return False, False
self.transmission_failed()
def calibrate_speed_settings(self):
self.speed_level = 0 # for now stay at lowest speed level
@ -236,4 +230,13 @@ class ARQSessionIRS(arq_session.ARQSession):
self.set_state(IRS_State.ABORTED)
self.event_manager.send_arq_session_finished(
False, self.id, self.dxcall, False, self.state.name, statistics=self.calculate_session_statistics())
return None, None
return None, None
def transmission_failed(self, irs_frame=None):
# final function for failed transmissions
self.session_ended = time.time()
self.set_state(IRS_State.FAILED)
self.log(f"Transmission failed!")
self.event_manager.send_arq_session_finished(True, self.id, self.dxcall,False, self.state.name, statistics=self.calculate_session_statistics())
self.states.setARQ(False)
return None, None

View file

@ -1,10 +1,10 @@
[NETWORK]
modemport = 3050
modemport = 5000
[STATION]
mycall = XX1XXX
mycall = AA1AAA
mygrid = AA12aa
myssid = 6
myssid = 1
ssid_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
enable_explorer = True
enable_stats = True

View file

@ -31,7 +31,6 @@ class CONFIG:
'control': str,
'serial_port': str,
'model_id': int,
'serial_port': str,
'serial_speed': int,
'data_bits': int,
'stop_bits': int,
@ -147,9 +146,7 @@ class CONFIG:
self.parser.set(section, setting, str(default_value))
self.log.info(f"[CFG] Adding missing setting: {section}.{setting}")
self.write_to_file()
return self.write_to_file()
# Handle special setting data type conversion
# is_writing means data from a dict being writen to the config file
@ -177,7 +174,6 @@ class CONFIG:
def write(self, data):
# Validate config data before writing
self.validate_data(data)
for section in data:
# init section if it doesn't exist yet
if not section.upper() in self.parser.keys():
@ -186,9 +182,11 @@ class CONFIG:
for setting in data[section]:
new_value = self.handle_setting(
section, setting, data[section][setting], True)
self.parser[section][setting] = str(new_value)
self.write_to_file()
try:
self.parser[section][setting] = str(new_value)
except Exception as e:
self.log.error("[CFG] error setting config key", e=e)
return self.write_to_file()
def write_to_file(self):
# Write config data to file

View file

@ -94,10 +94,10 @@ def index():
def config():
if request.method in ['POST']:
set_config = app.config_manager.write(request.json)
app.modem_service.put("restart")
if not set_config:
response = api_response(None, 'error writing config')
else:
app.modem_service.put("restart")
response = api_response(set_config)
return response
elif request.method == 'GET':
@ -222,10 +222,11 @@ def post_modem_send_raw_stop():
if not app.state_manager.is_modem_running:
api_abort('Modem not running', 503)
for id in app.state_manager.arq_irs_sessions:
app.state_manager.arq_irs_sessions[id].abort_transmission()
for id in app.state_manager.arq_iss_sessions:
app.state_manager.arq_iss_sessions[id].abort_transmission()
if app.state_manager.getARQ():
for id in app.state_manager.arq_irs_sessions:
app.state_manager.arq_irs_sessions[id].abort_transmission()
for id in app.state_manager.arq_iss_sessions:
app.state_manager.arq_iss_sessions[id].abort_transmission()
return api_response(request.json)

View file

@ -130,11 +130,11 @@ class TestARQSession(unittest.TestCase):
def testARQSessionSmallPayload(self):
# set Packet Error Rate (PER) / frame loss probability
self.loss_probability = 0
self.loss_probability = 30
self.establishChannels()
params = {
'dxcall': "XX1XXX-1",
'dxcall': "AA1AAA-1",
'data': base64.b64encode(bytes("Hello world!", encoding="utf-8")),
'type': "raw_lzma"
}
@ -149,7 +149,7 @@ class TestARQSession(unittest.TestCase):
self.establishChannels()
params = {
'dxcall': "XX1XXX-1",
'dxcall': "AA1AAA-1",
'data': base64.b64encode(np.random.bytes(1000)),
'type': "raw_lzma"
}
@ -165,7 +165,7 @@ class TestARQSession(unittest.TestCase):
self.establishChannels()
params = {
'dxcall': "XX1XXX-1",
'dxcall': "AA1AAA-1",
'data': base64.b64encode(np.random.bytes(100)),
}
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
@ -184,7 +184,7 @@ class TestARQSession(unittest.TestCase):
self.establishChannels()
params = {
'dxcall': "XX1XXX-1",
'dxcall': "AA1AAA-1",
'data': base64.b64encode(np.random.bytes(100)),
}
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
@ -200,7 +200,7 @@ class TestARQSession(unittest.TestCase):
def testSessionCleanupISS(self):
params = {
'dxcall': "XX1XXX-1",
'dxcall': "AA1AAA-1",
'data': base64.b64encode(np.random.bytes(100)),
}
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)