2021-12-02 08:01:18 +01:00
|
|
|
# -*- 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.
|
2023-06-19 17:16:00 +02:00
|
|
|
Also downloaded images will be stored on the filesystem of the OBC and can be
|
|
|
|
transferred via CFDP.
|
2021-12-02 08:01:18 +01:00
|
|
|
@author J. Meier
|
|
|
|
@date 29.11.2021
|
|
|
|
"""
|
|
|
|
import struct
|
|
|
|
|
|
|
|
from spacepackets.ecss.tc import PusTelecommand
|
2023-11-10 19:23:06 +01:00
|
|
|
from tmtccmd.tmtc import DefaultPusQueueHelper
|
2022-07-08 16:25:46 +02:00
|
|
|
from tmtccmd.util import ObjectIdU32
|
2021-12-02 08:01:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Commands:
|
|
|
|
UPLOAD_IMAGE = 0
|
|
|
|
DOWNLOAD_IMAGE = 1
|
|
|
|
|
|
|
|
|
|
|
|
class ImagePathDefs:
|
|
|
|
uploadFile = "/mnt/sd0/startracker/gemma.bin"
|
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_str_img_helper_command(
|
|
|
|
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
|
|
|
|
):
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd(
|
|
|
|
f"Testing star tracker image helper object id: {object_id.as_hex_string}"
|
2021-12-02 08:01:18 +01:00
|
|
|
)
|
|
|
|
if op_code == "0":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Star tracker image helper: Upload image")
|
2022-01-18 14:03:56 +01:00
|
|
|
command = (
|
2022-07-04 17:59:09 +02:00
|
|
|
object_id.as_bytes
|
2022-01-18 14:03:56 +01:00
|
|
|
+ struct.pack("!I", Commands.UPLOAD_IMAGE)
|
|
|
|
+ bytearray(ImagePathDefs.uploadFile, "utf-8")
|
|
|
|
)
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|