From 42c10c5780040c78dee2384637a4bd6dca9f2d97 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Tue, 9 Mar 2021 14:01:54 +0100 Subject: [PATCH] updated other signalling frams with callsign crc8 --- data_handler.py | 45 +++++++++++++++++++++++++++++++++------------ modem.py | 6 ++---- sock.py | 5 +++-- static.py | 6 +----- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/data_handler.py b/data_handler.py index 20e61133..6d6f7a49 100644 --- a/data_handler.py +++ b/data_handler.py @@ -84,9 +84,14 @@ def arq_data_received(data_in): logging.info("ARQ | TX | BURST ACK") #BUILDING ACK FRAME FOR BURST ----------------------------------------------- - ack_payload = b'ACK' - ack_frame = b'<' + ack_payload # < = 60 - + #ack_payload = b'ACK' + #ack_frame = b'<' + ack_payload # < = 60 + + ack_frame = bytearray(14) + ack_frame[:1] = bytes([60]) + ack_frame[1:2] = static.DXCALLSIGN_CRC8 + ack_frame[2:3] = static.MYCALLSIGN_CRC8 + #TRANSMIT ACK FRAME FOR BURST----------------------------------------------- modem.transmit_signalling(ack_frame) static.CHANNEL_STATE = 'RECEIVING_DATA' @@ -118,9 +123,14 @@ def arq_data_received(data_in): logging.warning("ARQ | TX | RPT ARQ FRAMES [" + str(missing_frames) + "] [BER."+str(static.BER)+"]") #BUILDING RPT FRAME FOR BURST ----------------------------------------------- - rpt_payload = missing_frames - rpt_frame = b'>' + rpt_payload #> = 63 --> 62?!?!?!?! - + #rpt_payload = missing_frames + #rpt_frame = b'>' + rpt_payload #> = 63 --> 62?!?!?!?! + rpt_frame = bytearray(14) + rpt_frame[:1] = bytes([63]) + rpt_frame[1:2] = static.DXCALLSIGN_CRC8 + rpt_frame[2:3] = static.MYCALLSIGN_CRC8 + rpt_frame[3:9] = missing_frames + #TRANSMIT RPT FRAME FOR BURST----------------------------------------------- modem.transmit_signalling(rpt_frame) static.CHANNEL_STATE = 'RECEIVING_DATA' @@ -173,8 +183,13 @@ def arq_data_received(data_in): static.RX_BUFFER.append(complete_data_frame) #BUILDING ACK FRAME FOR DATA FRAME ----------------------------------------------- - ack_payload = b'FRAME_ACK' - ack_frame = b'='+ ack_payload + bytes(static.FRAME_CRC) # < = 61 + #ack_payload = b'FRAME_ACK' + #ack_frame = b'='+ ack_payload + bytes(static.FRAME_CRC) # < = 61 + + ack_frame = bytearray(14) + ack_frame[:1] = bytes([61]) + ack_frame[1:2] = static.DXCALLSIGN_CRC8 + ack_frame[2:3] = static.MYCALLSIGN_CRC8 #TRANSMIT ACK FRAME FOR BURST----------------------------------------------- time.sleep(1) #0.5 @@ -613,14 +628,19 @@ async def arq_disconnect(): static.ARQ_SEND_KEEP_ALIVE == False static.ARQ_STATE = 'DISCONNECTING' logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "] <-> ["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]") - frame_type = bytes([222]) - disconnection_frame = frame_type + static.MYCALLSIGN + #frame_type = bytes([222]) + #disconnection_frame = frame_type + static.MYCALLSIGN + + disc_frame = bytearray(14) + disc_frame[:1] = bytes([222]) + disc_frame[1:2] = static.DXCALLSIGN_CRC8 + disc_frame[2:3] = static.MYCALLSIGN_CRC8 while static.CHANNEL_STATE == 'SENDING_SIGNALLING': time.sleep(0.01) await asyncio.sleep(5) - modem.transmit_signalling(disconnection_frame) + modem.transmit_signalling(disc_frame) logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "]< X >["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]") static.ARQ_STATE = 'IDLE' @@ -657,6 +677,7 @@ def transmit_ping(callsign): while static.CHANNEL_STATE == 'SENDING_SIGNALLING': time.sleep(0.01) modem.transmit_signalling(ping_frame) + def received_ping(data_in): @@ -693,7 +714,7 @@ async def transmit_cq(): cq_frame = bytearray(14) cq_frame[:1] = bytes([200]) - cq_frame[1:2] = b'\x01' #b'\x00' + cq_frame[1:2] = b'\x01' cq_frame[2:3] = static.MYCALLSIGN_CRC8 cq_frame[3:9] = static.MYCALLSIGN diff --git a/modem.py b/modem.py index 4ad8cba9..2707daee 100644 --- a/modem.py +++ b/modem.py @@ -75,7 +75,6 @@ class RF(): self.my_rig = Hamlib.Rig(Hamlib.RIG_MODEL_DUMMY) self.my_rig.set_conf("rig_pathname", "/dev/Rig") self.my_rig.set_conf("retry", "5") - self.my_rig.open () @@ -135,9 +134,8 @@ class RF(): txbuffer += bytes(mod_out_preamble) txbuffer += bytes(mod_out) - # -------------- transmit audio twice - - logging.debug("SEND SIGNALLING FRAME " + str(ack_buffer)) + # -------------- transmit audio + logging.debug("SENDING SIGNALLING FRAME " + str(ack_buffer)) self.stream_tx.write(bytes(txbuffer)) self.my_rig.set_ptt(self.hamlib_ptt_type,0) diff --git a/sock.py b/sock.py index 425dfd64..407a8a06 100644 --- a/sock.py +++ b/sock.py @@ -11,13 +11,14 @@ import threading import logging import time import json +import asyncio import static import data_handler import helpers -import fec -import asyncio + + class CMDTCPRequestHandler(socketserver.BaseRequestHandler): diff --git a/static.py b/static.py index 6087349f..5a72e26f 100644 --- a/static.py +++ b/static.py @@ -62,7 +62,7 @@ PTT_STATE = False # FreeDV Defaults FREEDV_RECEIVE = True -FREEDV_DATA_MODE = 12 +FREEDV_DATA_MODE = 12 #check if we can delete this FREEDV_SIGNALLING_MODE = 14 FREEDV_DATA_BYTES_PER_FRAME = 0 @@ -161,10 +161,6 @@ CHANNEL_STATE = 'RECEIVING_SIGNALLING' TNC_STATE = 'IDLE' # MODE FOR SENDING AN RECEIVING DATA DURING ARQ SESSION -# 0 = NOT WAITING FOR DATA -# 1 = TELL DX STATION WE WANT TO SEND DATA -# 2 = DX STATION IS READY FOR DATA -# 3 = DX STATION SAID, THEY ARE READY FOR DATA ARQ_READY_FOR_DATA = False ARQ_DATA_CHANNEL_MODE = 12