Improve ARQ tests and log messages

This commit is contained in:
Pedro 2023-12-06 11:47:47 +01:00
parent 9074e8e5eb
commit c689b93ee1
3 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@ class ARQSession():
] ]
SIZE_BY_SPEED = [ SIZE_BY_SPEED = [
] ]
def __init__(self, config: dict, tx_frame_queue: queue.Queue, dxcall: str): def __init__(self, config: dict, tx_frame_queue: queue.Queue, dxcall: str):
@ -32,6 +32,7 @@ class ARQSession():
return self.MODE_BY_SPEED[speed_level] return self.MODE_BY_SPEED[speed_level]
def transmit_frame(self, frame: bytearray): def transmit_frame(self, frame: bytearray):
self.logger.info("Transmitting frame")
modem_queue_item = { modem_queue_item = {
'mode': self.get_mode_by_speed_level(self.speed_level), 'mode': self.get_mode_by_speed_level(self.speed_level),
'repeat': 1, 'repeat': 1,

View file

@ -34,11 +34,8 @@ class ARQSessionISS(arq_session.ARQSession):
def generate_id(self): def generate_id(self):
return random.randint(1,255) return random.randint(1,255)
def log(self, message):
pass
def set_state(self, state): def set_state(self, state):
self.log(f"ARQ Session {self.id} state {self.state}") self.logger.info(f"ARQ Session {self.id} state {self.state}")
self.state = state self.state = state
def runner(self): def runner(self):
@ -59,6 +56,7 @@ class ARQSessionISS(arq_session.ARQSession):
retries = self.RETRIES_CONNECT retries = self.RETRIES_CONNECT
while retries > 0: while retries > 0:
self.transmit_frame(connect_frame) self.transmit_frame(connect_frame)
self.logger.info("Waiting for CONN ACK...")
if self.event_connection_ack_received.wait(self.TIMEOUT_CONNECT_ACK): if self.event_connection_ack_received.wait(self.TIMEOUT_CONNECT_ACK):
self.setState(self.STATE_CONNECTED) self.setState(self.STATE_CONNECTED)
return True return True

View file

@ -52,7 +52,8 @@ class TestARQSession(unittest.TestCase):
frame_bytes = bytes(transmission_item['frame']) frame_bytes = bytes(transmission_item['frame'])
if random.randint(0, 100) < self.loss_probability: if random.randint(0, 100) < self.loss_probability:
self.logger.info("Frame lost...") self.logger.info("Frame lost...")
next continue
self.logger.info("Redirecting frame")
frame_dispatcher.new_process_data(frame_bytes, None, len(frame_bytes), 0, 0) frame_dispatcher.new_process_data(frame_bytes, None, len(frame_bytes), 0, 0)
def establishChannels(self): def establishChannels(self):