eive-tmtc/pus_tc/devs/str_img_helper.py

39 lines
1.2 KiB
Python
Raw Normal View History

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.
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
2022-07-04 17:59:09 +02:00
from tmtccmd.tc import QueueHelper
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-07-05 02:12:54 +02:00
def pack_str_img_helper_command(object_id: ObjectIdU32, q: QueueHelper, 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))