mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
rigctld port fix and stuck in re opening data channel
data channel stuck in opening process when opening datachannel failed
This commit is contained in:
parent
43aa469633
commit
1e109da2e4
|
@ -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()
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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,22 +695,24 @@ 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)
|
||||
|
||||
# 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):
|
||||
|
||||
|
@ -731,6 +735,7 @@ class DATA():
|
|||
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)
|
||||
for attempt in range(1,DATA_CHANNEL_MAX_RETRIES+1):
|
||||
|
@ -759,10 +764,12 @@ 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):
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -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,8 +50,8 @@ 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()
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue