mirror of
https://github.com/craigerl/aprsd.git
synced 2025-09-17 05:57:48 -04:00
Fix for KISS/Fake client drivers
They were both missing a setting of aprsd_keepalive to test for the logging of the keepalive last time called.
This commit is contained in:
parent
24f567224c
commit
edeba7f514
@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@ -20,6 +21,9 @@ class APRSDFakeClient(metaclass=trace.TraceWrapperMetaclass):
|
|||||||
# flag to tell us to stop
|
# flag to tell us to stop
|
||||||
thread_stop = False
|
thread_stop = False
|
||||||
|
|
||||||
|
# date for last time we heard from the server
|
||||||
|
aprsd_keepalive = datetime.datetime.now()
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
path = []
|
path = []
|
||||||
|
|
||||||
@ -63,6 +67,7 @@ class APRSDFakeClient(metaclass=trace.TraceWrapperMetaclass):
|
|||||||
raw = 'GTOWN>APDW16,WIDE1-1,WIDE2-1:}KM6LYW-9>APZ100,TCPIP,GTOWN*::KM6LYW :KM6LYW: 19 Miles SW'
|
raw = 'GTOWN>APDW16,WIDE1-1,WIDE2-1:}KM6LYW-9>APZ100,TCPIP,GTOWN*::KM6LYW :KM6LYW: 19 Miles SW'
|
||||||
pkt_raw = aprslib.parse(raw)
|
pkt_raw = aprslib.parse(raw)
|
||||||
pkt = core.factory(pkt_raw)
|
pkt = core.factory(pkt_raw)
|
||||||
|
self.aprsd_keepalive = datetime.datetime.now()
|
||||||
callback(packet=pkt)
|
callback(packet=pkt)
|
||||||
LOG.debug(f'END blocking FAKE consumer {self}')
|
LOG.debug(f'END blocking FAKE consumer {self}')
|
||||||
time.sleep(8)
|
time.sleep(8)
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from ax253 import Frame
|
|
||||||
import kiss
|
import kiss
|
||||||
|
from ax253 import Frame
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from aprsd import conf # noqa
|
from aprsd import conf # noqa
|
||||||
from aprsd.packets import core
|
from aprsd.packets import core
|
||||||
from aprsd.utils import trace
|
from aprsd.utils import trace
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger("APRSD")
|
LOG = logging.getLogger('APRSD')
|
||||||
|
|
||||||
|
|
||||||
class KISS3Client:
|
class KISS3Client:
|
||||||
path = []
|
path = []
|
||||||
|
|
||||||
|
# date for last time we heard from the server
|
||||||
|
aprsd_keepalive = datetime.datetime.now()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
@ -26,7 +29,7 @@ class KISS3Client:
|
|||||||
# we can be TCP kiss or Serial kiss
|
# we can be TCP kiss or Serial kiss
|
||||||
if CONF.kiss_serial.enabled:
|
if CONF.kiss_serial.enabled:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"KISS({}) Serial connection to {}".format(
|
'KISS({}) Serial connection to {}'.format(
|
||||||
kiss.__version__,
|
kiss.__version__,
|
||||||
CONF.kiss_serial.device,
|
CONF.kiss_serial.device,
|
||||||
),
|
),
|
||||||
@ -39,7 +42,7 @@ class KISS3Client:
|
|||||||
self.path = CONF.kiss_serial.path
|
self.path = CONF.kiss_serial.path
|
||||||
elif CONF.kiss_tcp.enabled:
|
elif CONF.kiss_tcp.enabled:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"KISS({}) TCP Connection to {}:{}".format(
|
'KISS({}) TCP Connection to {}:{}'.format(
|
||||||
kiss.__version__,
|
kiss.__version__,
|
||||||
CONF.kiss_tcp.host,
|
CONF.kiss_tcp.host,
|
||||||
CONF.kiss_tcp.port,
|
CONF.kiss_tcp.port,
|
||||||
@ -52,7 +55,7 @@ class KISS3Client:
|
|||||||
)
|
)
|
||||||
self.path = CONF.kiss_tcp.path
|
self.path = CONF.kiss_tcp.path
|
||||||
|
|
||||||
LOG.debug("Starting KISS interface connection")
|
LOG.debug('Starting KISS interface connection')
|
||||||
self.kiss.start()
|
self.kiss.start()
|
||||||
|
|
||||||
@trace.trace
|
@trace.trace
|
||||||
@ -74,18 +77,19 @@ class KISS3Client:
|
|||||||
frame = Frame.from_bytes(frame_bytes)
|
frame = Frame.from_bytes(frame_bytes)
|
||||||
# Now parse it with aprslib
|
# Now parse it with aprslib
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"frame": frame,
|
'frame': frame,
|
||||||
}
|
}
|
||||||
self._parse_callback(**kwargs)
|
self._parse_callback(**kwargs)
|
||||||
|
self.aprsd_keepalive = datetime.datetime.now()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.error("Failed to parse bytes received from KISS interface.")
|
LOG.error('Failed to parse bytes received from KISS interface.')
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
|
|
||||||
def consumer(self, callback):
|
def consumer(self, callback):
|
||||||
LOG.debug("Start blocking KISS consumer")
|
LOG.debug('Start blocking KISS consumer')
|
||||||
self._parse_callback = callback
|
self._parse_callback = callback
|
||||||
self.kiss.read(callback=self.parse_frame, min_frames=None)
|
self.kiss.read(callback=self.parse_frame, min_frames=None)
|
||||||
LOG.debug(f"END blocking KISS consumer {self.kiss}")
|
LOG.debug(f'END blocking KISS consumer {self.kiss}')
|
||||||
|
|
||||||
def send(self, packet):
|
def send(self, packet):
|
||||||
"""Send an APRS Message object."""
|
"""Send an APRS Message object."""
|
||||||
@ -94,24 +98,24 @@ class KISS3Client:
|
|||||||
path = self.path
|
path = self.path
|
||||||
if isinstance(packet, core.Packet):
|
if isinstance(packet, core.Packet):
|
||||||
packet.prepare()
|
packet.prepare()
|
||||||
payload = packet.payload.encode("US-ASCII")
|
payload = packet.payload.encode('US-ASCII')
|
||||||
if packet.path:
|
if packet.path:
|
||||||
path = packet.path
|
path = packet.path
|
||||||
else:
|
else:
|
||||||
msg_payload = f"{packet.raw}{{{str(packet.msgNo)}"
|
msg_payload = f'{packet.raw}{{{str(packet.msgNo)}'
|
||||||
payload = (
|
payload = (
|
||||||
":{:<9}:{}".format(
|
':{:<9}:{}'.format(
|
||||||
packet.to_call,
|
packet.to_call,
|
||||||
msg_payload,
|
msg_payload,
|
||||||
)
|
)
|
||||||
).encode("US-ASCII")
|
).encode('US-ASCII')
|
||||||
|
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
f"KISS Send '{payload}' TO '{packet.to_call}' From "
|
f"KISS Send '{payload}' TO '{packet.to_call}' From "
|
||||||
f"'{packet.from_call}' with PATH '{path}'",
|
f"'{packet.from_call}' with PATH '{path}'",
|
||||||
)
|
)
|
||||||
frame = Frame.ui(
|
frame = Frame.ui(
|
||||||
destination="APZ100",
|
destination='APZ100',
|
||||||
source=packet.from_call,
|
source=packet.from_call,
|
||||||
path=path,
|
path=path,
|
||||||
info=payload,
|
info=payload,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user