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
|
// 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})
|
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
|
||||||
collapseFirstRow.hide()
|
collapseFirstRow.hide()
|
||||||
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
|
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
|
||||||
|
@ -391,7 +393,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
collapseThirdRow.show()
|
collapseThirdRow.show()
|
||||||
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
|
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
|
||||||
collapseFourthRow.show()
|
collapseFourthRow.show()
|
||||||
|
*/
|
||||||
// overriding settings for rigctl / direct
|
// overriding settings for rigctl / direct
|
||||||
if (document.getElementById("radio-control-switch2").checked){
|
if (document.getElementById("radio-control-switch2").checked){
|
||||||
var radiocontrol = 'rigctl'
|
var radiocontrol = 'rigctl'
|
||||||
|
@ -419,17 +421,18 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
|
|
||||||
// collapse settings screen
|
// 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})
|
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
|
||||||
collapseFirstRow.show()
|
collapseFirstRow.show()
|
||||||
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
|
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
|
||||||
collapseSecondRow.show()
|
collapseSecondRow.show()
|
||||||
|
|
||||||
|
|
||||||
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
|
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
|
||||||
collapseThirdRow.hide()
|
collapseThirdRow.hide()
|
||||||
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
|
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
|
||||||
collapseFourthRow.hide()
|
collapseFourthRow.hide()
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ class DATA():
|
||||||
|
|
||||||
def worker_transmit(self):
|
def worker_transmit(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
data = self.data_queue_transmit.get()
|
data = self.data_queue_transmit.get()
|
||||||
# [0] Command
|
# [0] Command
|
||||||
|
|
||||||
|
@ -107,6 +108,7 @@ class DATA():
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# wrong command
|
# wrong command
|
||||||
|
print(f"wrong command {data}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -604,7 +606,7 @@ class DATA():
|
||||||
#print("not ready for data...leaving loop....")
|
#print("not ready for data...leaving loop....")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.calculate_transfer_rate_tx(tx_start_of_transmission, bufferposition_end, len(data_out))
|
||||||
# NEXT ATTEMPT
|
# 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)
|
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):
|
def open_dc_and_transmit(self, data_out:bytes, mode:int, n_frames_per_burst:int):
|
||||||
|
|
||||||
static.TNC_STATE = 'BUSY'
|
static.TNC_STATE = 'BUSY'
|
||||||
|
self.datachannel_timeout = False
|
||||||
|
|
||||||
# we need to compress data for gettin a compression factor.
|
# 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
|
# so we are compressing twice. This is not that nice and maybe theres another way
|
||||||
# for calculating transmission statistics
|
# for calculating transmission statistics
|
||||||
static.ARQ_COMPRESSION_FACTOR = len(data_out) / len(zlib.compress(data_out))
|
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
|
# 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)
|
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):
|
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
|
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[10:12] = data_len.to_bytes(2, byteorder='big')
|
||||||
connection_frame[12:13] = bytes([compression_factor])
|
connection_frame[12:13] = bytes([compression_factor])
|
||||||
connection_frame[13:14] = bytes([n_frames_per_burst])
|
connection_frame[13:14] = bytes([n_frames_per_burst])
|
||||||
|
|
||||||
|
|
||||||
while not static.ARQ_STATE:
|
while not static.ARQ_STATE:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
@ -759,11 +764,13 @@ class DATA():
|
||||||
static.INFO.append("DATACHANNEL;FAILED")
|
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') + "]")
|
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:
|
if not TESTMODE:
|
||||||
self.arq_cleanup()
|
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):
|
def arq_received_data_channel_opener(self, data_in:bytes):
|
||||||
|
|
||||||
static.INFO.append("DATACHANNEL;RECEIVEDOPENER")
|
static.INFO.append("DATACHANNEL;RECEIVEDOPENER")
|
||||||
|
@ -796,6 +803,14 @@ class DATA():
|
||||||
static.ARQ_STATE = True
|
static.ARQ_STATE = True
|
||||||
static.TNC_STATE = 'BUSY'
|
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())
|
self.data_channel_last_received = int(time.time())
|
||||||
|
|
||||||
connection_frame = bytearray(14)
|
connection_frame = bytearray(14)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import structlog
|
||||||
import log_handler
|
import log_handler
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
import static
|
||||||
# class taken from darsidelemm
|
# class taken from darsidelemm
|
||||||
# rigctl - https://github.com/darksidelemm/rotctld-web-gui/blob/master/rotatorgui.py#L35
|
# 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):
|
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.hostname = rigctld_ip
|
||||||
self.ip = rigctld_port
|
self.port = int(rigctld_port)
|
||||||
|
|
||||||
|
|
||||||
if self.connect():
|
if self.connect():
|
||||||
|
@ -49,9 +50,9 @@ class radio():
|
||||||
# ConnectionRefusedError: [Errno 111] Connection refused
|
# ConnectionRefusedError: [Errno 111] Connection refused
|
||||||
self.connected = False
|
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)
|
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):
|
def close_rig(self):
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
|
@ -185,8 +185,9 @@ def process_tnc_commands(data):
|
||||||
rawdata = {"dt": "f", "fn": filename, "ft": filetype,"d": data, "crc": checksum}
|
rawdata = {"dt": "f", "fn": filename, "ft": filetype,"d": data, "crc": checksum}
|
||||||
dataframe = json.dumps(rawdata)
|
dataframe = json.dumps(rawdata)
|
||||||
data_out = bytes(dataframe, 'utf-8')
|
data_out = bytes(dataframe, 'utf-8')
|
||||||
|
print("kommen wir hier an?!?")
|
||||||
data_handler.DATA_QUEUE_TRANSMIT.put(['ARQ_FILE', data_out, mode, n_frames])
|
data_handler.DATA_QUEUE_TRANSMIT.put(['ARQ_FILE', data_out, mode, n_frames])
|
||||||
|
print(data_handler.DATA_QUEUE_TRANSMIT.qsize())
|
||||||
# TRANSMIT MESSAGE ----------------------------------------------------------
|
# TRANSMIT MESSAGE ----------------------------------------------------------
|
||||||
if received_json["type"] == 'ARQ' and received_json["command"] == "sendMessage":
|
if received_json["type"] == 'ARQ' and received_json["command"] == "sendMessage":
|
||||||
static.TNC_STATE = 'BUSY'
|
static.TNC_STATE = 'BUSY'
|
||||||
|
|
Loading…
Reference in a new issue