From 71bc5621891c1e659a3bcfe0b241db6a14396b9b Mon Sep 17 00:00:00 2001 From: Paul Kronenwetter Date: Sun, 19 Jun 2022 16:45:06 -0400 Subject: [PATCH 1/2] Fix for issue #218. --- tnc/data_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tnc/data_handler.py b/tnc/data_handler.py index f5676303..9f55a86c 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -1560,7 +1560,7 @@ class DATA: # Update data_channel timestamp self.data_channel_last_received = int(time.time()) - if static.LOW_BANDWIDTH_MODE and mode == 255: + if static.LOW_BANDWIDTH_MODE: frametype = bytes([227]) self.log.debug("[TNC] Requesting low bandwidth mode") From baa9ece4ad76830992e3ee7c7cfd87318e68af6d Mon Sep 17 00:00:00 2001 From: Paul Kronenwetter Date: Sun, 19 Jun 2022 16:45:31 -0400 Subject: [PATCH 2/2] Add test case to detect in the future --- test/test_chat_text.py | 4 ++-- test/util_chat_text_1.py | 25 ++++++++++++++++++++++++- test/util_chat_text_2.py | 4 ++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/test/test_chat_text.py b/test/test_chat_text.py index aacdf2a4..c5db2c8d 100644 --- a/test/test_chat_text.py +++ b/test/test_chat_text.py @@ -175,7 +175,7 @@ def test_chat_text( STATIONS[0], STATIONS[1], messages[message_no], - freedv_mode == "datac3", # low bandwidth mode + freedv_mode == "datac3", # == low bandwidth mode tmp_path, ), daemon=True, @@ -189,7 +189,7 @@ def test_chat_text( STATIONS[1], STATIONS[0], messages[message_no], - freedv_mode == "datac3", # low bandwidth mode + freedv_mode == "datac3", # == low bandwidth mode tmp_path, ), daemon=True, diff --git a/test/util_chat_text_1.py b/test/util_chat_text_1.py index 329b7bcd..cb0c175d 100644 --- a/test/util_chat_text_1.py +++ b/test/util_chat_text_1.py @@ -100,7 +100,30 @@ def t_highsnr_arq_short_station1( # log.info("S1 TX: ", frames=t_frames) for item in t_frames: frametype = int.from_bytes(item[:1], "big") # type: ignore - log.info("S1 TX: ", TX=frametype) + log.info("S1 TX: ", mode=static.FRAME_TYPE(frametype).name) + + if ( + static.LOW_BANDWIDTH_MODE + and frametype == static.FRAME_TYPE.ARQ_DC_OPEN_W.value + ): + mesg = ( + "enqueue_frame_for_tx: Low BW global " + "but DC Open narrow frame NOT chosen." + ) + # Low bandwidth data type, wide bandwidth frame type + log.error(mesg) + assert False, mesg + if ( + not static.LOW_BANDWIDTH_MODE + and frametype == static.FRAME_TYPE.ARQ_DC_OPEN_N.value + ): + mesg = ( + "enqueue_frame_for_tx: High BW global " + "but DC Open wide frame NOT chosen." + ) + # High bandwidth data type, low bandwidth frame type + log.error(mesg) + assert False, mesg # Apologies for the Python "magic." "orig_func" is a pointer to the # original function captured before this one was put in place. diff --git a/test/util_chat_text_2.py b/test/util_chat_text_2.py index 2b9285e8..92a000d9 100644 --- a/test/util_chat_text_2.py +++ b/test/util_chat_text_2.py @@ -146,7 +146,7 @@ def t_highsnr_arq_short_station2( timeout = time.time() + 20 while '"arq":"session","status":"close"' not in str(sock.SOCKET_QUEUE.queue): if time.time() > timeout: - log.error("station2", TIMEOUT=True) + log.warning("station2", TIMEOUT=True) break time.sleep(0.5) log.info("station2", arq_state=pformat(static.ARQ_STATE)) @@ -158,4 +158,4 @@ def t_highsnr_arq_short_station2( assert '"arq":"transmission","status":"received"' in str(sock.SOCKET_QUEUE.queue) assert '"arq":"session","status":"close"' in str(sock.SOCKET_QUEUE.queue) - log.error("station2: Exiting!") + log.warning("station2: Exiting!")