separate function for raw TM insertion
All checks were successful
EIVE/-/pipeline/pr-main This commit looks good
All checks were successful
EIVE/-/pipeline/pr-main This commit looks good
This commit is contained in:
parent
57a225f926
commit
2259d269dd
@ -12,7 +12,8 @@ from spacepackets.util import UnsignedByteField
|
|||||||
|
|
||||||
|
|
||||||
TM_DB_PATH = "tm.db"
|
TM_DB_PATH = "tm.db"
|
||||||
RAW_TM_PATH = "raw_tm.db"
|
# Separate DB or not? Not sure..
|
||||||
|
# RAW_TM_PATH = "raw_tm.db"
|
||||||
|
|
||||||
PUS_APID = 0x65
|
PUS_APID = 0x65
|
||||||
CFDP_APID = 0x66
|
CFDP_APID = 0x66
|
||||||
|
@ -17,7 +17,7 @@ from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice
|
|||||||
from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm
|
from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm
|
||||||
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice
|
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice
|
||||||
from tmtccmd.tmtc import GenericApidHandlerBase, SpecificApidHandlerBase
|
from tmtccmd.tmtc import GenericApidHandlerBase, SpecificApidHandlerBase
|
||||||
from eive_tmtc.config.definitions import TM_DB_PATH, PUS_APID, RAW_TM_PATH
|
from eive_tmtc.config.definitions import TM_DB_PATH, PUS_APID
|
||||||
|
|
||||||
from eive_tmtc.config.object_ids import get_object_ids
|
from eive_tmtc.config.object_ids import get_object_ids
|
||||||
|
|
||||||
@ -58,9 +58,6 @@ class PusHandler(SpecificApidHandlerBase):
|
|||||||
packet: bytes,
|
packet: bytes,
|
||||||
):
|
):
|
||||||
packet_uuid = uuid.uuid4()
|
packet_uuid = uuid.uuid4()
|
||||||
db_con = sqlite3.connect(TM_DB_PATH)
|
|
||||||
raw_tm_db_con = sqlite3.connect(RAW_TM_PATH)
|
|
||||||
raw_tm_db_con.execute("INSERT ")
|
|
||||||
if len(packet) < 8:
|
if len(packet) < 8:
|
||||||
_LOGGER.warning("Detected packet shorter than 8 bytes!")
|
_LOGGER.warning("Detected packet shorter than 8 bytes!")
|
||||||
return
|
return
|
||||||
@ -72,6 +69,8 @@ class PusHandler(SpecificApidHandlerBase):
|
|||||||
_LOGGER.warning("Could not generate PUS TM object from raw data")
|
_LOGGER.warning("Could not generate PUS TM object from raw data")
|
||||||
_LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
|
_LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
|
||||||
return
|
return
|
||||||
|
db_con = sqlite3.connect(TM_DB_PATH)
|
||||||
|
self._store_packet_in_db(db_con, packet, tm_packet, packet_uuid)
|
||||||
service = tm_packet.service
|
service = tm_packet.service
|
||||||
dedicated_handler = True
|
dedicated_handler = True
|
||||||
if service == 1:
|
if service == 1:
|
||||||
@ -113,6 +112,39 @@ class PusHandler(SpecificApidHandlerBase):
|
|||||||
self.printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet)
|
self.printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet)
|
||||||
self.raw_logger.log_tm(tm_packet)
|
self.raw_logger.log_tm(tm_packet)
|
||||||
|
|
||||||
|
def _store_packet_in_db(
|
||||||
|
self,
|
||||||
|
db_con: sqlite3.Connection,
|
||||||
|
packet: bytes,
|
||||||
|
tm_packet: PusTelemetry,
|
||||||
|
packet_uuid: uuid.UUID,
|
||||||
|
):
|
||||||
|
cursor = db_con.cursor()
|
||||||
|
assert tm_packet.time_provider is not None
|
||||||
|
cursor.execute(
|
||||||
|
"""
|
||||||
|
CREATE TABLE IF NOT EXISTS pus_tm(
|
||||||
|
packet_uuid TEXT PRIMARY KEY,
|
||||||
|
generation_time TEXT,
|
||||||
|
service NUM,
|
||||||
|
subservice NUM,
|
||||||
|
data_len NUM,
|
||||||
|
raw_data BLOB
|
||||||
|
)"""
|
||||||
|
)
|
||||||
|
cursor.execute(
|
||||||
|
"INSERT INTO pus_tm VALUES(?, ?, ?, ?, ?, ?)",
|
||||||
|
(
|
||||||
|
str(packet_uuid),
|
||||||
|
tm_packet.time_provider.as_datetime(),
|
||||||
|
tm_packet.service,
|
||||||
|
tm_packet.subservice,
|
||||||
|
len(packet),
|
||||||
|
packet,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
db_con.commit()
|
||||||
|
|
||||||
def _handle_param_packet(self, raw_data: bytes, tm_packet: PusTelemetry):
|
def _handle_param_packet(self, raw_data: bytes, tm_packet: PusTelemetry):
|
||||||
param_packet = Service20FsfwTm.unpack(
|
param_packet = Service20FsfwTm.unpack(
|
||||||
raw_telemetry=raw_data, time_reader=CdsShortTimestamp.empty()
|
raw_telemetry=raw_data, time_reader=CdsShortTimestamp.empty()
|
||||||
|
Loading…
Reference in New Issue
Block a user