1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-21 23:55:17 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
3e8716365e another fix for tx send 2024-04-15 11:29:26 -04:00
758ea432ed removed Packet.last_send_attempt and just use send_count 2024-04-15 10:00:35 -04:00
1c9f25a3b3 Fix access to PacketList._maxlen 2024-04-15 09:19:05 -04:00
5 changed files with 13 additions and 8 deletions

View File

@ -102,7 +102,6 @@ class Packet:
send_count: int = field(repr=False, default=0, compare=False, hash=False) send_count: int = field(repr=False, default=0, compare=False, hash=False)
retry_count: int = field(repr=False, default=3, compare=False, hash=False) retry_count: int = field(repr=False, default=3, compare=False, hash=False)
last_send_time: float = field(repr=False, default=0, compare=False, hash=False) last_send_time: float = field(repr=False, default=0, compare=False, hash=False)
last_send_attempt: int = field(repr=False, default=0, compare=False, hash=False)
# Do we allow this packet to be saved to send later? # Do we allow this packet to be saved to send later?
allow_delay: bool = field(repr=False, default=True, compare=False, hash=False) allow_delay: bool = field(repr=False, default=True, compare=False, hash=False)

View File

@ -18,12 +18,13 @@ class PacketList(objectstore.ObjectStoreMixin):
lock = threading.Lock() lock = threading.Lock()
_total_rx: int = 0 _total_rx: int = 0
_total_tx: int = 0 _total_tx: int = 0
_maxlen: int = 100
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
if cls._instance is None: if cls._instance is None:
cls._instance = super().__new__(cls) cls._instance = super().__new__(cls)
cls._maxlen = CONF.packet_list_maxlen cls._instance._maxlen = CONF.packet_list_maxlen
cls.data = { cls._instance.data = {
"types": {}, "types": {},
"packets": OrderedDict(), "packets": OrderedDict(),
} }
@ -58,7 +59,7 @@ class PacketList(objectstore.ObjectStoreMixin):
def _add(self, packet): def _add(self, packet):
if packet.key in self.data["packets"]: if packet.key in self.data["packets"]:
self.data["packets"].move_to_end(packet.key) self.data["packets"].move_to_end(packet.key)
elif len(self.data["packets"]) == self.maxlen: elif len(self.data["packets"]) == self._maxlen:
self.data["packets"].popitem(last=False) self.data["packets"].popitem(last=False)
self.data["packets"][packet.key] = packet self.data["packets"][packet.key] = packet

View File

@ -26,10 +26,16 @@ class SeenList(objectstore.ObjectStoreMixin):
cls._instance.data = {} cls._instance.data = {}
return cls._instance return cls._instance
@wrapt.synchronized(lock)
def stats(self, serializable=False): def stats(self, serializable=False):
"""Return the stats for the PacketTrack class.""" """Return the stats for the PacketTrack class."""
return self.data return self.data
@wrapt.synchronized(lock)
def copy(self):
"""Return a copy of the data."""
return self.data.copy()
@wrapt.synchronized(lock) @wrapt.synchronized(lock)
def update_seen(self, packet): def update_seen(self, packet):
callsign = None callsign = None

View File

@ -65,10 +65,9 @@ class PacketTrack(objectstore.ObjectStoreMixin):
pkts = {} pkts = {}
for key in self.data: for key in self.data:
last_send_time = self.data[key].last_send_time last_send_time = self.data[key].last_send_time
last_send_attempt = self.data[key]._last_send_attempt
pkts[key] = { pkts[key] = {
"last_send_time": last_send_time, "last_send_time": last_send_time,
"last_send_attempt": last_send_attempt, "send_count": self.data[key].send_count,
"retry_count": self.data[key].retry_count, "retry_count": self.data[key].retry_count,
"message": self.data[key].raw, "message": self.data[key].raw,
} }
@ -82,7 +81,7 @@ class PacketTrack(objectstore.ObjectStoreMixin):
@wrapt.synchronized(lock) @wrapt.synchronized(lock)
def add(self, packet): def add(self, packet):
key = packet.msgNo key = packet.msgNo
packet._last_send_attempt = 0 packet.send_count = 0
self.data[key] = packet self.data[key] = packet
self.total_tracked += 1 self.total_tracked += 1

View File

@ -118,7 +118,7 @@ class SendPacketThread(aprsd_threads.APRSDThread):
return False return False
else: else:
send_now = False send_now = False
if packet.send_count == packet.retry_count: if packet.send_count >= packet.retry_count:
# we reached the send limit, don't send again # we reached the send limit, don't send again
# TODO(hemna) - Need to put this in a delayed queue? # TODO(hemna) - Need to put this in a delayed queue?
LOG.info( LOG.info(