mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
and another global has been eliminated..
This commit is contained in:
parent
27209ff843
commit
6682bf360a
2 changed files with 18 additions and 17 deletions
|
@ -689,14 +689,14 @@ class DATA:
|
||||||
data_in = bytes(data_in)
|
data_in = bytes(data_in)
|
||||||
|
|
||||||
# only process data if we are in ARQ and BUSY state else return to quit
|
# only process data if we are in ARQ and BUSY state else return to quit
|
||||||
if not self.states.is_arq_state and Modem.modem_state not in ["BUSY"]:
|
if not self.states.is_arq_state and not self.states.is_modem_busy:
|
||||||
self.log.warning("[Modem] wrong modem state - dropping data", is_arq_state=self.states.is_arq_state,
|
self.log.warning("[Modem] wrong modem state - dropping data", is_arq_state=self.states.is_arq_state,
|
||||||
modem_state=Modem.modem_state)
|
modem_state=self.states.is_modem_busy)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.arq_file_transfer = True
|
self.arq_file_transfer = True
|
||||||
|
|
||||||
Modem.modem_state = "BUSY"
|
self.states.set("is_modem_busy", True)
|
||||||
self.states.set("is_arq_state", True)
|
self.states.set("is_arq_state", True)
|
||||||
|
|
||||||
# Update data_channel timestamp
|
# Update data_channel timestamp
|
||||||
|
@ -1662,7 +1662,7 @@ class DATA:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Only process data if we are in ARQ and BUSY state
|
# Only process data if we are in ARQ and BUSY state
|
||||||
if not self.states.is_arq_state or Modem.modem_state != "BUSY":
|
if not self.states.is_arq_state or not self.states.is_modem_busy:
|
||||||
return
|
return
|
||||||
self.dxgrid = b'------'
|
self.dxgrid = b'------'
|
||||||
helpers.add_to_heard_stations(
|
helpers.add_to_heard_stations(
|
||||||
|
@ -1907,7 +1907,7 @@ class DATA:
|
||||||
self.states.arq_session_state,
|
self.states.arq_session_state,
|
||||||
)
|
)
|
||||||
ARQ.arq_session = True
|
ARQ.arq_session = True
|
||||||
Modem.modem_state = "BUSY"
|
self.states.set("is_modem_busy", True)
|
||||||
|
|
||||||
self.send_data_to_socket_queue(
|
self.send_data_to_socket_queue(
|
||||||
freedata="modem-message",
|
freedata="modem-message",
|
||||||
|
@ -2000,7 +2000,7 @@ class DATA:
|
||||||
def transmit_session_heartbeat(self) -> None:
|
def transmit_session_heartbeat(self) -> None:
|
||||||
"""Send ARQ sesion heartbeat while connected"""
|
"""Send ARQ sesion heartbeat while connected"""
|
||||||
# ARQ.arq_session = True
|
# ARQ.arq_session = True
|
||||||
# Modem.modem_state = "BUSY"
|
# self.states.set("is_modem_busy", True)
|
||||||
# self.states.set("arq_session_state", "connected")
|
# self.states.set("arq_session_state", "connected")
|
||||||
|
|
||||||
connection_frame = bytearray(self.length_sig0_frame)
|
connection_frame = bytearray(self.length_sig0_frame)
|
||||||
|
@ -2051,7 +2051,7 @@ class DATA:
|
||||||
|
|
||||||
ARQ.arq_session = True
|
ARQ.arq_session = True
|
||||||
self.states.set("arq_session_state", "connected")
|
self.states.set("arq_session_state", "connected")
|
||||||
Modem.modem_state = "BUSY"
|
self.states.set("is_modem_busy", True)
|
||||||
|
|
||||||
# Update the timeout timestamps
|
# Update the timeout timestamps
|
||||||
self.arq_session_last_received = int(time.time())
|
self.arq_session_last_received = int(time.time())
|
||||||
|
@ -2104,7 +2104,7 @@ class DATA:
|
||||||
# override session connection attempts
|
# override session connection attempts
|
||||||
self.data_channel_max_retries = attempts
|
self.data_channel_max_retries = attempts
|
||||||
|
|
||||||
Modem.modem_state = "BUSY"
|
self.states.set("is_modem_busy", True)
|
||||||
self.arq_file_transfer = True
|
self.arq_file_transfer = True
|
||||||
|
|
||||||
self.transmission_uuid = transmission_uuid
|
self.transmission_uuid = transmission_uuid
|
||||||
|
@ -2236,7 +2236,7 @@ class DATA:
|
||||||
|
|
||||||
if self.states.is_arq_state_event.is_set():
|
if self.states.is_arq_state_event.is_set():
|
||||||
return True
|
return True
|
||||||
if Modem.modem_state in ["IDLE"]:
|
if not self.states.is_modem_busy:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# `data_channel_max_retries` attempts have been sent. Aborting attempt & cleaning up
|
# `data_channel_max_retries` attempts have been sent. Aborting attempt & cleaning up
|
||||||
|
@ -2259,7 +2259,7 @@ class DATA:
|
||||||
|
|
||||||
# stop processing if not in arq session, but modem state is busy and we have a different session id
|
# stop processing if not in arq session, but modem state is busy and we have a different session id
|
||||||
# use-case we get a connection request while connecting to another station
|
# use-case we get a connection request while connecting to another station
|
||||||
if not ARQ.arq_session and Modem.modem_state in ["BUSY"] and data_in[13:14] != self.session_id:
|
if not ARQ.arq_session and self.states.is_modem_busy and data_in[13:14] != self.session_id:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.arq_file_transfer = True
|
self.arq_file_transfer = True
|
||||||
|
@ -2380,7 +2380,7 @@ class DATA:
|
||||||
# Set ARQ State AFTER resetting timeouts
|
# Set ARQ State AFTER resetting timeouts
|
||||||
# this avoids timeouts starting too early
|
# this avoids timeouts starting too early
|
||||||
self.states.set("is_arq_state", True)
|
self.states.set("is_arq_state", True)
|
||||||
Modem.modem_state = "BUSY"
|
self.states.set("is_modem_busy", True)
|
||||||
|
|
||||||
self.reset_statistics()
|
self.reset_statistics()
|
||||||
|
|
||||||
|
@ -2676,7 +2676,7 @@ class DATA:
|
||||||
snr=snr,
|
snr=snr,
|
||||||
dxsnr=dxsnr,
|
dxsnr=dxsnr,
|
||||||
)
|
)
|
||||||
Modem.modem_state = "IDLE"
|
self.states.set("is_modem_busy", False)
|
||||||
else:
|
else:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"[Modem] FOREIGN PING ACK ["
|
"[Modem] FOREIGN PING ACK ["
|
||||||
|
@ -2719,7 +2719,7 @@ class DATA:
|
||||||
Received a transmission stop
|
Received a transmission stop
|
||||||
"""
|
"""
|
||||||
self.log.warning("[Modem] Stopping transmission!")
|
self.log.warning("[Modem] Stopping transmission!")
|
||||||
Modem.modem_state = "IDLE"
|
self.states.set("is_modem_busy", False)
|
||||||
self.states.set("is_arq_state", False)
|
self.states.set("is_arq_state", False)
|
||||||
self.send_data_to_socket_queue(
|
self.send_data_to_socket_queue(
|
||||||
freedata="modem-message",
|
freedata="modem-message",
|
||||||
|
@ -2751,7 +2751,7 @@ class DATA:
|
||||||
and not self.arq_file_transfer
|
and not self.arq_file_transfer
|
||||||
and not self.beacon_paused
|
and not self.beacon_paused
|
||||||
#and not self.states.channel_busy
|
#and not self.states.channel_busy
|
||||||
and Modem.modem_state not in ["BUSY"]
|
and not self.states.is_modem_busy
|
||||||
and not self.states.is_arq_state
|
and not self.states.is_arq_state
|
||||||
):
|
):
|
||||||
self.send_data_to_socket_queue(
|
self.send_data_to_socket_queue(
|
||||||
|
@ -3200,7 +3200,7 @@ class DATA:
|
||||||
|
|
||||||
# we need to keep these values if in ARQ_SESSION
|
# we need to keep these values if in ARQ_SESSION
|
||||||
if not ARQ.arq_session:
|
if not ARQ.arq_session:
|
||||||
Modem.modem_state = "IDLE"
|
self.states.set("is_modem_busy", False)
|
||||||
self.dxcallsign = b"AA0AA-0"
|
self.dxcallsign = b"AA0AA-0"
|
||||||
self.mycallsign = self.mycallsign
|
self.mycallsign = self.mycallsign
|
||||||
self.session_id = bytes(1)
|
self.session_id = bytes(1)
|
||||||
|
@ -3414,7 +3414,7 @@ class DATA:
|
||||||
DATA CHANNEL
|
DATA CHANNEL
|
||||||
"""
|
"""
|
||||||
# and not static.ARQ_SEND_KEEP_ALIVE:
|
# and not static.ARQ_SEND_KEEP_ALIVE:
|
||||||
if self.states.is_arq_state and Modem.modem_state == "BUSY":
|
if self.states.is_arq_state and self.states.is_modem_busy:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
if (
|
if (
|
||||||
self.data_channel_last_received + self.transmission_timeout
|
self.data_channel_last_received + self.transmission_timeout
|
||||||
|
@ -3457,7 +3457,7 @@ class DATA:
|
||||||
"""
|
"""
|
||||||
if (
|
if (
|
||||||
ARQ.arq_session
|
ARQ.arq_session
|
||||||
and Modem.modem_state == "BUSY"
|
and self.states.is_modem_busy
|
||||||
and not self.arq_file_transfer
|
and not self.arq_file_transfer
|
||||||
):
|
):
|
||||||
if self.arq_session_last_received + self.arq_session_timeout > time.time():
|
if self.arq_session_last_received + self.arq_session_timeout > time.time():
|
||||||
|
|
|
@ -15,6 +15,7 @@ class STATES:
|
||||||
self.channel_busy_slot = [False, False, False, False, False]
|
self.channel_busy_slot = [False, False, False, False, False]
|
||||||
self.is_codec2_traffic = False
|
self.is_codec2_traffic = False
|
||||||
self.is_modem_running = False
|
self.is_modem_running = False
|
||||||
|
self.is_modem_busy = False
|
||||||
self.is_beacon_running = False
|
self.is_beacon_running = False
|
||||||
self.is_arq_state = False
|
self.is_arq_state = False
|
||||||
self.is_arq_session = False
|
self.is_arq_session = False
|
||||||
|
|
Loading…
Reference in a new issue