diff --git a/modem/broadcast.py b/modem/broadcast.py index 8c51c475..71dd2882 100644 --- a/modem/broadcast.py +++ b/modem/broadcast.py @@ -110,7 +110,7 @@ class broadcastHandler: + str(self.fec_wakeup_callsign, "UTF-8") + "] ", mode=self.wakeup_mode, bursts=self.broadcast_payload_bursts, ) - # TODO: We need a dynamic way of modifying this + # TODO We need a dynamic way of modifying this modem.RECEIVE_DATAC4 = False self.fec_wakeup_callsign = bytes() self.wakeup_received = False diff --git a/modem/data_handler.py b/modem/data_handler.py index a7a66055..54192bf1 100644 --- a/modem/data_handler.py +++ b/modem/data_handler.py @@ -138,8 +138,8 @@ class DATA: self.snr_list_high_bw = [-100, 0, 3] # List for time to wait for corresponding mode in seconds # test with 6,7 --> caused sometimes a frame timeout if ack frame takes longer - # TODO: Need to check why ACK frames needs more time - # TODO: Adjust these times + # TODO Need to check why ACK frames needs more time + # TODO Adjust these times self.time_list_high_bw = [6 + self.duration_sig0_frame + 1, 6 + self.duration_sig0_frame + 1, 6 + self.duration_sig0_frame + 1] # -------------- AVAILABLE MODES END----------- @@ -479,7 +479,7 @@ class DATA: type=frame_type) # Set the TRANSMITTING flag before adding an object to the transmit queue - # TODO: This is not that nice, we could improve this somehow + # TODO This is not that nice, we could improve this somehow Modem.transmitting = True modem.MODEM_TRANSMIT_QUEUE.put([c2_mode, copies, repeat_delay, frame_to_tx]) @@ -570,7 +570,7 @@ class DATA: # reset burst timeout in case we had to wait too long self.burst_last_received = time.time() + channel_busy_timeout + 8 # Transmit frame - # TODO: Do we have to send , self.send_ident_frame(False) ? + # TODO Do we have to send , self.send_ident_frame(False) ? # self.enqueue_frame_for_tx([ack_frame, self.send_ident_frame(False)], c2_mode=FREEDV_MODE.sig1.value, copies=3, repeat_delay=0) self.enqueue_frame_for_tx([ack_frame], c2_mode=FREEDV_MODE.sig1.value, copies=3, repeat_delay=0) @@ -604,7 +604,7 @@ class DATA: nack_frame[4:8] = len(ARQ.rx_frame_buffer).to_bytes(4, byteorder="big") # TRANSMIT NACK FRAME FOR BURST - # TODO: Do we have to send ident frame? + # TODO Do we have to send ident frame? # self.enqueue_frame_for_tx([ack_frame, self.send_ident_frame(False)], c2_mode=FREEDV_MODE.sig1.value, copies=3, repeat_delay=0) # wait while timeout not reached and our busy state is busy @@ -654,11 +654,11 @@ class DATA: disconnection_frame[:1] = bytes([FR_TYPE.ARQ_SESSION_CLOSE.value]) disconnection_frame[1:2] = self.session_id disconnection_frame[2:5] = Station.dxcallsign_crc - # TODO: Needed? disconnection_frame[7:13] = helpers.callsign_to_bytes(self.mycallsign) + # TODO Needed? disconnection_frame[7:13] = helpers.callsign_to_bytes(self.mycallsign) # self.enqueue_frame_for_tx([disconnection_frame, self.send_ident_frame(False)], c2_mode=FREEDV_MODE.sig0.value, copies=5, repeat_delay=0) - # TODO: We need to add the ident frame feature with a seperate PR after publishing latest protocol - # TODO: We need to wait some time between last arq related signalling frame and ident frame - # TODO: Maybe about 500ms - 1500ms to avoid confusion and too much PTT toggles + # TODO We need to add the ident frame feature with a seperate PR after publishing latest protocol + # TODO We need to wait some time between last arq related signalling frame and ident frame + # TODO Maybe about 500ms - 1500ms to avoid confusion and too much PTT toggles # wait while timeout not reached and our busy state is busy channel_busy_timeout = time.time() + 5 @@ -736,7 +736,7 @@ class DATA: # free up burst buffer ARQ.rx_burst_buffer = [] - # TODO: Needs to be removed as soon as mode error is fixed + # TODO Needs to be removed as soon as mode error is fixed # catch possible modem error which leads into false byteorder # modem possibly decodes too late - data then is pushed to buffer # which leads into wrong byteorder @@ -851,7 +851,7 @@ class DATA: # # Check if we received last frame of burst - this is an indicator for missed frames. # # With this way of doing this, we always MUST receive the last # # frame of a burst otherwise the entire burst is lost - # # TODO: See if a timeout on the send side with re-transmit last burst would help. + # # TODO See if a timeout on the send side with re-transmit last burst would help. # self.log.debug( # "[Modem] last frames of burst received:", # frame=self.rx_n_frame_of_burst, @@ -1742,7 +1742,7 @@ class DATA: Station.dxcallsign = self.dxcallsign Station.dxcallsign_crc = helpers.get_crc_24(self.dxcallsign) - # TODO: we need to check this, maybe placing it to class init + # TODO we need to check this, maybe placing it to class init self.datachannel_timeout = False self.log.info( "[Modem] SESSION [" @@ -2406,7 +2406,7 @@ class DATA: # initially set speed_level 0 in case of bad SNR and no matching mode self.speed_level = 0 - # TODO: MOVE THIS TO arq_calculate_speed_level() + # TODO MOVE THIS TO arq_calculate_speed_level() # calculate speed level in correlation to latest known SNR for i in range(len(self.mode_list)): if ModemParam.snr >= self.snr_list[i]: @@ -2578,7 +2578,7 @@ class DATA: dxcallsign=str(self.dxcallsign, 'UTF-8'), irs=helpers.bool_to_string(self.is_IRS) ) - # TODO: We should display a message to this effect on the UI. + # TODO We should display a message to this effect on the UI. self.log.warning( "[Modem] protocol version mismatch:", received=protocol_version, @@ -2596,7 +2596,7 @@ class DATA: """ if not str(dxcallsign).strip(): - # TODO: We should display a message to this effect on the UI. + # TODO We should display a message to this effect on the UI. self.log.warning("[Modem] Missing required callsign", dxcallsign=dxcallsign) return Station.dxcallsign = dxcallsign @@ -2775,7 +2775,7 @@ class DATA: stop_frame[:1] = bytes([FR_TYPE.ARQ_STOP.value]) stop_frame[1:4] = Station.dxcallsign_crc stop_frame[4:7] = Station.mycallsign_crc - # TODO: Not sure if we really need the session id when disconnecting + # TODO Not sure if we really need the session id when disconnecting # stop_frame[1:2] = self.session_id stop_frame[7:13] = helpers.callsign_to_bytes(self.mycallsign) @@ -3347,7 +3347,7 @@ class DATA: DATA BURST """ # IRS SIDE - # TODO: We need to redesign this part for cleaner state handling + # TODO We need to redesign this part for cleaner state handling # Return if not ARQ STATE and not ARQ SESSION STATE as they are different use cases if ( not ARQ.arq_state @@ -3376,7 +3376,7 @@ class DATA: frames_left = 1 timeout = self.burst_last_received + (self.time_list[self.speed_level] * frames_left) - # TODO: Enable this for development + # TODO Enable this for development # print(f"timeout expected in:{round(timeout - time.time())} | frames left: {frames_left} of {self.rx_n_frames_per_burst} | speed level: {self.speed_level}") if timeout <= time.time() or modem_error_state: self.log.warning( @@ -3409,7 +3409,7 @@ class DATA: self.speed_level = max(self.speed_level - 1, 0) ARQ.arq_speed_level = self.speed_level - # TODO: Create better mechanisms for handling n frames per burst for bad channels + # TODO Create better mechanisms for handling n frames per burst for bad channels # reduce frames per burst if self.burst_rpt_counter >= 2: tx_n_frames_per_burst = max(self.rx_n_frames_per_burst - 1, 1) @@ -3419,11 +3419,11 @@ class DATA: # Update modes we are listening to self.set_listening_modes(True, True, self.mode_list[self.speed_level]) - # TODO: Does SNR make sense for NACK if we dont have an actual SNR information? + # TODO Does SNR make sense for NACK if we dont have an actual SNR information? self.send_burst_nack_frame_watchdog(0, tx_n_frames_per_burst) # Update data_channel timestamp - # TODO: Disabled this one for testing. + # TODO Disabled this one for testing. # self.data_channel_last_received = time.time() self.n_retries_per_burst += 1 else: diff --git a/modem/helpers.py b/modem/helpers.py index 59f69860..a2ca5026 100644 --- a/modem/helpers.py +++ b/modem/helpers.py @@ -599,7 +599,7 @@ def search_hmac_salt(dxcallsign: bytes, mycallsign: bytes, search_token, data_fr key = token_list[len(token_list) - _][:-1] key = bytes(key, "utf-8") search_digest = hmac.new(key, data_frame, hashlib.sha256).digest()[:4] - # TODO: Remove this debugging information if not needed anymore + # TODO Remove this debugging information if not needed anymore # print("-----------------------------------------") # print(_) # print(f" key-------------{key}") diff --git a/modem/mesh.py b/modem/mesh.py index fc4f0f2b..a08303ef 100644 --- a/modem/mesh.py +++ b/modem/mesh.py @@ -15,7 +15,7 @@ HF mesh networking prototype and testing module -TODO: SIGNALLING FOR ACK/NACK: +TODO SIGNALLING FOR ACK/NACK: - mesh-signalling burst is datac13 - mesh-signalling frame contains [message id, status, hops, score, payload] - frame type is 1 byte @@ -29,7 +29,7 @@ TODO: SIGNALLING FOR ACK/NACK: - if done already in list, don't reset retry counter - delete ACK/NACK if "done" and timestamp older than 1day -TODO: SCORE CALCULATION: +TODO SCORE CALCULATION: SNR: negative --> * 2 """ @@ -412,7 +412,7 @@ class MeshRouter(): self.add_mesh_ping_to_signalling_table(destination, origin, frametype="PING", status="forwarding") def received_mesh_ping_ack(self, data_in): - # TODO: + # TODO # Check if we have a ping callsign already in signalling table # if PING, then override and make it a PING-ACK # if not, then add to table @@ -540,7 +540,7 @@ class MeshRouter(): type=frame_type) # Set the TRANSMITTING flag before adding an object to the transmit queue - # TODO: This is not that nice, we could improve this somehow + # TODO This is not that nice, we could improve this somehow Modem.transmitting = True modem.MODEM_TRANSMIT_QUEUE.put([c2_mode, copies, repeat_delay, frame_to_tx]) diff --git a/modem/modem.py b/modem/modem.py index 823a6eff..cf77a653 100644 --- a/modem/modem.py +++ b/modem/modem.py @@ -467,7 +467,7 @@ class RF: AudioParam.audio_record_file.writeframes(x) # Avoid decoding when transmitting to reduce CPU - # TODO: Overriding this for testing purposes + # TODO Overriding this for testing purposes # if not Modem.transmitting: length_x = len(x) # Avoid buffer overflow by filling only if buffer for @@ -492,7 +492,7 @@ class RF: self.fft_data = x else: if not HamlibParam.ptt_state: - # TODO: Moved to this place for testing + # TODO Moved to this place for testing # Maybe we can avoid moments of silence before transmitting HamlibParam.ptt_state = self.radio.set_ptt(True) jsondata = {"ptt": "True"} @@ -546,7 +546,7 @@ class RF: ModemParam.channel_busy = False start_of_transmission = time.time() - # TODO: Moved ptt toggle some steps before audio is ready for testing + # TODO Moved ptt toggle some steps before audio is ready for testing # Toggle ptt early to save some time and send ptt state via socket # HamlibParam.ptt_state = self.radio.set_ptt(True) # jsondata = {"ptt": "True"} @@ -1095,7 +1095,7 @@ class RF: """Worker for FIFO queue for processing frames to be transmitted""" while True: # print queue size for debugging purposes - # TODO: Lets check why we have several frames in our transmit queue which causes sometimes a double transmission + # TODO Lets check why we have several frames in our transmit queue which causes sometimes a double transmission # we could do a cleanup after a transmission so theres no reason sending twice queuesize = self.modem_transmit_queue.qsize() self.log.debug("[MDM] self.modem_transmit_queue", qsize=queuesize) @@ -1330,7 +1330,7 @@ class RF: # Reduce area where the busy detection is enabled # We want to have this in correlation with mode bandwidth - # TODO: This is not correctly and needs to be checked for correct maths + # TODO This is not correctly and needs to be checked for correct maths # dfftlist[0:1] = 10,15Hz # Bandwidth[Hz] / 10,15 # narrowband = 563Hz = 56 @@ -1456,7 +1456,7 @@ def get_bytes_per_frame(mode: int) -> int: :rtype: int """ freedv = open_codec2_instance(mode) - # TODO: add close session + # TODO add close session # get number of bytes per frame for mode return int(codec2.api.freedv_get_bits_per_modem_frame(freedv) / 8) diff --git a/modem/sock.py b/modem/sock.py index 783efaac..121c35a1 100644 --- a/modem/sock.py +++ b/modem/sock.py @@ -92,7 +92,7 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler): client.send(sock_data) except Exception as err: self.log.info("[SCK] Connection lost", e=err) - # TODO: Check if we really should set connection alive to false. + # TODO Check if we really should set connection alive to false. # This might disconnect all other clients as well... self.connection_alive = False except Exception as err: @@ -722,7 +722,7 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler): # wait some random time helpers.wait(randrange(5, 25, 5) / 10.0) - # TODO: carefully test this + # TODO carefully test this # avoid sending data while we are receiving codec2 signalling data interrupt_time = time.time() + 5 while ModemParam.is_codec2_traffic and time.time() < interrupt_time: @@ -854,7 +854,7 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler): def modem_get_rx_buffer(self, received_json): try: if not RX_BUFFER.empty(): - # TODO: REMOVE DEPRECATED MESSAGES + # TODO REMOVE DEPRECATED MESSAGES #output = { # "command": "rx_buffer", # "data-array": [],