eive-tmtc/pus_tc/devs/str_img_helper.py
2022-07-08 16:25:46 +02:00

39 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
"""
@file str_img_helper.py
@brief Commanding of the star tracker image helper object which is responsible for uploading
and downloading images to/from the star tracker.
@details Images to uplaod must be previously transferred to the OBC with the CFDP protocol.
Also downloaded images will be stored on the filesystem of the OBC and can be transferred via CFDP.
@author J. Meier
@date 29.11.2021
"""
import struct
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc import QueueHelper
from tmtccmd.util import ObjectIdU32
class Commands:
UPLOAD_IMAGE = 0
DOWNLOAD_IMAGE = 1
class ImagePathDefs:
uploadFile = "/mnt/sd0/startracker/gemma.bin"
def pack_str_img_helper_command(object_id: ObjectIdU32, q: QueueHelper, op_code: str):
q.add_log_cmd(
f"Testing star tracker image helper object id: {object_id.as_hex_string}"
)
if op_code == "0":
q.add_log_cmd("Star tracker image helper: Upload image")
command = (
object_id.as_bytes
+ struct.pack("!I", Commands.UPLOAD_IMAGE)
+ bytearray(ImagePathDefs.uploadFile, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))