diff --git a/gui/preload-main.js b/gui/preload-main.js index df59a415..e185e8dc 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -383,6 +383,8 @@ window.addEventListener('DOMContentLoaded', () => { // collapse settings screen + // deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay + /* var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false}) collapseFirstRow.hide() var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false}) @@ -391,7 +393,7 @@ window.addEventListener('DOMContentLoaded', () => { collapseThirdRow.show() var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false}) collapseFourthRow.show() - + */ // overriding settings for rigctl / direct if (document.getElementById("radio-control-switch2").checked){ var radiocontrol = 'rigctl' @@ -419,17 +421,18 @@ window.addEventListener('DOMContentLoaded', () => { // collapse settings screen + // deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay + /* var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false}) collapseFirstRow.show() var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false}) collapseSecondRow.show() - var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false}) collapseThirdRow.hide() var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false}) collapseFourthRow.hide() - + */ diff --git a/tnc/data_handler.py b/tnc/data_handler.py index d17eddaf..56356d47 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -68,6 +68,7 @@ class DATA(): def worker_transmit(self): while True: + data = self.data_queue_transmit.get() # [0] Command @@ -107,6 +108,7 @@ class DATA(): else: # wrong command + print(f"wrong command {data}") pass @@ -604,7 +606,7 @@ class DATA(): #print("not ready for data...leaving loop....") break - + self.calculate_transfer_rate_tx(tx_start_of_transmission, bufferposition_end, len(data_out)) # NEXT ATTEMPT structlog.get_logger("structlog").debug("ATTEMPT", retry=self.tx_n_retry_of_burst, maxretries=TX_N_MAX_RETRIES_PER_BURST,overflows=static.BUFFER_OVERFLOW_COUNTER) @@ -693,23 +695,25 @@ class DATA(): def open_dc_and_transmit(self, data_out:bytes, mode:int, n_frames_per_burst:int): - static.TNC_STATE = 'BUSY' + self.datachannel_timeout = False # we need to compress data for gettin a compression factor. # so we are compressing twice. This is not that nice and maybe theres another way # for calculating transmission statistics static.ARQ_COMPRESSION_FACTOR = len(data_out) / len(zlib.compress(data_out)) + self.arq_open_data_channel(mode, n_frames_per_burst) - - self.arq_open_data_channel(mode, n_frames_per_burst) # wait until data channel is open - while not static.ARQ_STATE: + while not static.ARQ_STATE and not self.datachannel_timeout: time.sleep(0.01) - - self.arq_transmit(data_out, mode, n_frames_per_burst) - + + if static.ARQ_STATE: + self.arq_transmit(data_out, mode, n_frames_per_burst) + else: + return False + def arq_open_data_channel(self, mode:int, n_frames_per_burst:int): DATA_CHANNEL_MAX_RETRIES = 5 # N attempts for connecting to another station @@ -730,6 +734,7 @@ class DATA(): #connection_frame[10:12] = data_len.to_bytes(2, byteorder='big') connection_frame[12:13] = bytes([compression_factor]) connection_frame[13:14] = bytes([n_frames_per_burst]) + while not static.ARQ_STATE: time.sleep(0.01) @@ -759,11 +764,13 @@ class DATA(): static.INFO.append("DATACHANNEL;FAILED") structlog.get_logger("structlog").warning("[TNC] ARQ | TX | DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]>>X<<[" + str(static.DXCALLSIGN, 'utf-8') + "]") + self.datachannel_timeout = True if not TESTMODE: self.arq_cleanup() - sys.exit() # close thread and so connection attempts - - + + return False + #sys.exit() # close thread and so connection attempts + def arq_received_data_channel_opener(self, data_in:bytes): static.INFO.append("DATACHANNEL;RECEIVEDOPENER") @@ -796,6 +803,14 @@ class DATA(): static.ARQ_STATE = True static.TNC_STATE = 'BUSY' + # reset ARQ statistics + static.ARQ_BYTES_PER_MINUTE_BURST = 0 + static.ARQ_BYTES_PER_MINUTE = 0 + static.ARQ_BITS_PER_SECOND_BURST = 0 + static.ARQ_BITS_PER_SECOND = 0 + static.ARQ_TRANSMISSION_PERCENT = 0 + static.TOTAL_BYTES = 0 + self.data_channel_last_received = int(time.time()) connection_frame = bytearray(14) diff --git a/tnc/rigctld.py b/tnc/rigctld.py index fb1e6e1e..3f0ba3f0 100644 --- a/tnc/rigctld.py +++ b/tnc/rigctld.py @@ -4,6 +4,7 @@ import structlog import log_handler import logging import time +import static # class taken from darsidelemm # rigctl - https://github.com/darksidelemm/rotctld-web-gui/blob/master/rotatorgui.py#L35 # @@ -27,7 +28,7 @@ class radio(): def open_rig(self, devicename, deviceport, hamlib_ptt_type, serialspeed, pttport, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port): self.hostname = rigctld_ip - self.ip = rigctld_port + self.port = int(rigctld_port) if self.connect(): @@ -49,9 +50,9 @@ class radio(): # ConnectionRefusedError: [Errno 111] Connection refused self.connected = False structlog.get_logger("structlog").warning("[RIGCTLD] Re-Trying to establish a connection to rigctld!", attempt=a+1, ip=self.hostname, port=self.port) - time.sleep(1) - - + time.sleep(0.5) + return False + def close_rig(self): self.sock.close() self.connected = False diff --git a/tnc/sock.py b/tnc/sock.py index 99a3206b..6f6113fd 100644 --- a/tnc/sock.py +++ b/tnc/sock.py @@ -185,8 +185,9 @@ def process_tnc_commands(data): rawdata = {"dt": "f", "fn": filename, "ft": filetype,"d": data, "crc": checksum} dataframe = json.dumps(rawdata) data_out = bytes(dataframe, 'utf-8') + print("kommen wir hier an?!?") data_handler.DATA_QUEUE_TRANSMIT.put(['ARQ_FILE', data_out, mode, n_frames]) - + print(data_handler.DATA_QUEUE_TRANSMIT.qsize()) # TRANSMIT MESSAGE ---------------------------------------------------------- if received_json["type"] == 'ARQ' and received_json["command"] == "sendMessage": static.TNC_STATE = 'BUSY'