fixed data type for ARQ_STATE

This commit is contained in:
DJ2LS 2021-02-24 17:41:14 +01:00 committed by GitHub
parent 697106b567
commit 76aa3094fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 18 deletions

View file

@ -23,7 +23,7 @@ import helpers
def data_received(data_in):
static.TNC_STATE = b'BUSY'
static.TNC_STATE = 'BUSY'
static.ARQ_N_FRAME = int.from_bytes(bytes(data_in[:1]), "big") - 10 #get number of burst frame
static.ARQ_N_RX_FRAMES_PER_BURSTS = int.from_bytes(bytes(data_in[1:2]), "big") #get number of bursts from received frame
@ -189,7 +189,7 @@ def data_received(data_in):
static.ARQ_FRAME_BOF_RECEIVED = False
static.ARQ_FRAME_EOF_RECEIVED = False
static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME = 0
static.TNC_STATE = b'IDLE'
static.TNC_STATE = 'IDLE'
#print("----------------------------------------------------------------")
#print(static.RX_BUFFER[-1])
@ -197,7 +197,7 @@ def data_received(data_in):
else:
logging.error("ARQ | RX | DATA FRAME NOT SUCESSFULLY RECEIVED!")
static.ARQ_STATE = b'IDLE'
static.ARQ_STATE = 'IDLE'
@ -469,15 +469,16 @@ def arq_received_connect(data_in):
TRANSMIT_CONNECT_THREAD.start()
def arq_received_connect_keep_alive(data_in):
static.ARQ_STATE = 'CONNECTED'
logging.info("CONNECTED ["+ str(static.MYCALLSIGN, 'utf-8') + "] >< ["+ str(static.DXCALLSIGN, 'utf-8') + "]")
frame_type = bytes([221])
connection_frame = frame_type + static.MYCALLSIGN
if static.ARQ_STATE == 'CONNECTED' or static.ARQ_STATE == 'CONNECTING':
static.ARQ_STATE = 'CONNECTED'
logging.info("CONNECTED ["+ str(static.MYCALLSIGN, 'utf-8') + "] >< ["+ str(static.DXCALLSIGN, 'utf-8') + "]")
frame_type = bytes([221])
connection_frame = frame_type + static.MYCALLSIGN
acktimer = threading.Timer(3.0, modem.transmit_signalling, args=[connection_frame])
acktimer.start()
#TRANSMIT_CONNECT_THREAD = threading.Thread(target=modem.transmit_signalling, args=[connection_frame], name="TRANSMIT_ARQ")
#TRANSMIT_CONNECT_THREAD.start()
acktimer = threading.Timer(3.0, modem.transmit_signalling, args=[connection_frame])
acktimer.start()
#TRANSMIT_CONNECT_THREAD = threading.Thread(target=modem.transmit_signalling, args=[connection_frame], name="TRANSMIT_ARQ")
#TRANSMIT_CONNECT_THREAD.start()
def arq_disconnect():
@ -495,7 +496,7 @@ def arq_disconnect():
def arq_disconnect_received(data_in):
static.ARQ_STATE = 'DISCONNECTED'
logging.info("DISCONNECTED ["+ str(static.MYCALLSIGN, 'utf-8') + "] >< ["+ str(static.DXCALLSIGN, 'utf-8') + "]")
logging.info("DISCONNECTED ["+ str(static.MYCALLSIGN, 'utf-8') + "] < > ["+ str(static.DXCALLSIGN, 'utf-8') + "]")
static.ARQ_STATE = 'DISCONNECTED'
static.TNC_STATE = 'IDLE'
static.DXCALLSIGN = b''
@ -553,7 +554,7 @@ def transmit_beacon():
frame_type = bytes([230])
print(frame_type)
beacon_frame = frame_type + static.MYCALLSIGN
while static.TNC_STATE = 'BEACON':
while static.TNC_STATE == 'BEACON':
time.sleep(0.01)
beacontimer = threading.Timer(60.0, modem.transmit_signalling, args=[beacon_frame])
beacontimer.start()

View file

@ -60,11 +60,11 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
if data.startswith('ARQ:CONNECT:'):
arqconnectcommand = data.split('ARQ:CONNECT:')
dxcallsign = arqconnectcommand[1]
if static.ARQ_STATE == b'CONNECTED':
if static.ARQ_STATE == 'CONNECTED':
# here we should disconnect
pass
if static.TNC_STATE == b'IDLE':
if static.TNC_STATE == 'IDLE':
# here we send an "CONNECT FRAME
ARQ_CONNECT_THREAD = threading.Thread(target=data_handler.arq_connect, args=[dxcallsign], name="ARQ_CONNECT")
@ -83,7 +83,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
# wen need to change the TNC_STATE to "CONNECTE" and need to make sure we have a valid callsign and callsign crc8 of the DX station
if data.startswith('ARQ:DATA') and static.TNC_STATE == b'IDLE':
logging.info("CMD | NEW ARQ DATA")
static.TNC_STATE = b'BUSY'
static.TNC_STATE = 'BUSY'
arqdata = data.split('ARQ:')
data_out = bytes(arqdata[1], 'utf-8')

View file

@ -159,7 +159,7 @@ CHANNEL_STATE = 'RECEIVING_SIGNALLING'
# IDLE
# CONNECTING
# DISCONNECTING
TNC_STATE = b'IDLE'
TNC_STATE = 'IDLE'