diff --git a/main.py b/main.py index 05234e9c..7b8a56ec 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,6 @@ import argparse import logging import threading - import static import helpers @@ -30,17 +29,17 @@ if __name__ == '__main__': parser.add_argument('--rx', dest="audio_input_device", default=0, help="sound card for listening.", type=int) parser.add_argument('--tx', dest="audio_output_device", default=0, help="sound card for transmitting.", type=int) parser.add_argument('--port', dest="socket_port", default=3000, help="Set the port, the socket is listening on.", type=int) - parser.add_argument('--mode', dest="freedv_data_mode", default=12, help="Set the mode.", type=int) + #parser.add_argument('--mode', dest="freedv_data_mode", default=12, help="Set the mode.", type=int) args = parser.parse_args() - static.FREEDV_DATA_MODE = args.freedv_data_mode + #static.FREEDV_DATA_MODE = args.freedv_data_mode static.AUDIO_INPUT_DEVICE = args.audio_input_device static.AUDIO_OUTPUT_DEVICE = args.audio_output_device static.PORT = args.socket_port #--------------------------------------------START CMD SERVER - import sock # we need to wait until we got all parameters from argparse + import sock # we need to wait until we got all parameters from argparse first before loading sock cmd_server_thread = threading.Thread(target=sock.start_cmd_socket, name="cmd server") cmd_server_thread.start() diff --git a/modem.py b/modem.py index fe0ce378..64b99511 100644 --- a/modem.py +++ b/modem.py @@ -281,10 +281,9 @@ class RF(): else: pass - #vars()['food'] - bytes_out = (ctypes.c_ubyte * bytes_per_frame) ################################################################## DATA BYTES PER FRAME SETZEN! + bytes_out = (ctypes.c_ubyte * bytes_per_frame) bytes_out = bytes_out() #get pointer to bytes_out while static.FREEDV_RECEIVE == True: @@ -301,12 +300,11 @@ class RF(): #demod loop while (static.CHANNEL_STATE == 'RECEIVING_DATA' and static.ARQ_DATA_CHANNEL_MODE == mode) or (static.CHANNEL_STATE == 'RECEIVING_SIGNALLING' and static.FREEDV_SIGNALLING_MODE == mode): - - + time.sleep(0.01) + # refresh vars, so the correct parameters of the used mode are set static.FREEDV_DATA_BYTES_PER_FRAME = bytes_per_frame static.FREEDV_DATA_PAYLOAD_PER_FRAME = bytes_per_frame - 2 - time.sleep(0.01) nin = self.c_lib.freedv_nin(freedv) #nin = int(nin*(static.AUDIO_SAMPLE_RATE_RX/static.MODEM_SAMPLE_RATE)) data_in = self.stream_rx.read(nin, exception_on_overflow = False) @@ -315,6 +313,7 @@ class RF(): nbytes = self.c_lib.freedv_rawdatarx(freedv, bytes_out, data_in) # demodulate audio #logging.debug(self.c_lib.freedv_get_rx_status(freedv)) #print("listening-" + str(mode) + "-" + str(self.c_lib.freedv_get_rx_status(freedv))) + #-------------STUCK IN SYNC DETECTOR stuck_in_sync_counter += 1 if self.c_lib.freedv_get_rx_status(freedv) == 10: @@ -337,11 +336,7 @@ class RF(): if nbytes == bytes_per_frame:##########################################################FREEDV_DATA_BYTES_PER_FRAME self.calculate_ber(freedv) - - - rxstatus = self.c_lib.freedv_get_rx_status(freedv) - #logging.debug("DATA-" + str(rxstatus)) - + # counter reset for stuck in sync counter stuck_in_sync_counter = 0 stuck_in_sync_10_counter = 0 @@ -429,9 +424,9 @@ class RF(): else: logging.info("OTHER FRAME: " + str(bytes_out[:-2])) print(frametype) + # DO UNSYNC AFTER LAST BURST by checking the frame nums agains the total frames per burst - if frame == n_frames_per_burst: - + if frame == n_frames_per_burst: logging.debug("LAST FRAME ---> UNSYNC") self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC @@ -439,7 +434,7 @@ class RF(): #logging.info("DATA-" + str(mode) + " " +str(rxstatus)) if rxstatus == 10: self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC - print(" -SYNC 10- Trigger - M:" + str(mode)) + logging.warning("MODEM | SYNC 10 TRIGGER | M:" + str(mode)) self.calculate_ber(freedv)