Fixed issue with packet tracker and msgNO Counter

The packet msgNo field is a string, but is typically is an integer
counter to keep track of a specific packet id.  The counter was
returning an int, but the packet.msgNo is a string.  So, when trying to
delete a packet from the packet tracker, the key for accessing the
packet is the msgNo, which has to be a string.  Passing an int, will
cause the packet tracker to not find the packet, and hence silently
fail.

This patch forces the msgNo counter to be a string.
This commit is contained in:
Hemna 2023-09-29 10:04:15 -04:00
parent f79b88ec1b
commit 9bdfd166fd
2 changed files with 5 additions and 12 deletions

View File

@ -62,14 +62,6 @@ class PacketTrack(objectstore.ObjectStoreMixin):
def __len__(self):
return len(self.data)
@wrapt.synchronized(lock)
def __str__(self):
result = "{"
for key in self.data.keys():
result += f"{key}: {str(self.data[key])}, "
result += "}"
return result
@wrapt.synchronized(lock)
def add(self, packet):
key = packet.msgNo
@ -78,13 +70,14 @@ class PacketTrack(objectstore.ObjectStoreMixin):
@wrapt.synchronized(lock)
def get(self, key):
if key in self.data:
return self.data[key]
return self.data.get(key, None)
@wrapt.synchronized(lock)
def remove(self, key):
if key in self.data.keys():
try:
del self.data[key]
except KeyError:
pass
def restart(self):
"""Walk the list of messages and restart them if any."""

View File

@ -37,7 +37,7 @@ class PacketCounter:
@property
@wrapt.synchronized(lock)
def value(self):
return self.val.value
return str(self.val.value)
@wrapt.synchronized(lock)
def __repr__(self):