meier/startracker #30

Merged
muellerr merged 5 commits from meier/startracker into develop 2022-01-02 16:31:15 +01:00
4 changed files with 80 additions and 3 deletions
Showing only changes of commit 58ec3c6640 - Show all commits

View File

@ -317,6 +317,9 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
"31": ("Star Tracker: Request contrast", {OpCodeDictKeys.TIMEOUT: 2.0}), "31": ("Star Tracker: Request contrast", {OpCodeDictKeys.TIMEOUT: 2.0}),
"32": ("Star Tracker: Set json filename", {OpCodeDictKeys.TIMEOUT: 2.0}), "32": ("Star Tracker: Set json filename", {OpCodeDictKeys.TIMEOUT: 2.0}),
"33": ("Star Tracker: Write", {OpCodeDictKeys.TIMEOUT: 2.0}), "33": ("Star Tracker: Write", {OpCodeDictKeys.TIMEOUT: 2.0}),
"34": ("Star Tracker: Read", {OpCodeDictKeys.TIMEOUT: 2.0}),
"35": ("Star Tracker: Set Read filename", {OpCodeDictKeys.TIMEOUT: 2.0}),
"36": ("Star Tracker: Get checksum", {OpCodeDictKeys.TIMEOUT: 2.0}),
} }
service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker)

View File

@ -78,7 +78,10 @@ def get_object_ids() -> Dict[bytes, list]:
GPS_HANDLER_1_ID: "GPS 1", GPS_HANDLER_1_ID: "GPS 1",
RAD_SENSOR_ID: "Radiation Sensor", RAD_SENSOR_ID: "Radiation Sensor",
PLOC_SUPV_ID: "PLOC Supervisor", PLOC_SUPV_ID: "PLOC Supervisor",
PLOC_MPSOC_ID: "PLOC MPSoC",
CORE_CONTROLLER_ID: "Core Controller", CORE_CONTROLLER_ID: "Core Controller",
CORE_CONTROLLER_ID: "CCSDS Handler", CCSDS_HANDLER_ID: "CCSDS Handler",
PDEC_HANDLER_ID: "PDEC Handler",
STAR_TRACKER_ID: "Star Tracker Handler",
}) })
return object_id_dict return object_id_dict

View File

@ -40,13 +40,14 @@ class StarTrackerActionIds:
VALIDATION = 48 VALIDATION = 48
ALGO = 49 ALGO = 49
CHECKSUM = 50 CHECKSUM = 50
RAED = 51 READ = 51
WRITE = 52 WRITE = 52
TAKE_IMAGE = 15 TAKE_IMAGE = 15
STOP_IMAGE_LOADER = 55 STOP_IMAGE_LOADER = 55
RESET_ERROR = 56 RESET_ERROR = 56
CHANGE_DOWNLOAD_IMAGE = 57 CHANGE_DOWNLOAD_IMAGE = 57
SET_JSON_FILE_NAME = 58 SET_JSON_FILE_NAME = 58
SET_READ_FILENAME = 59
class ImagePathDefs: class ImagePathDefs:
@ -55,6 +56,22 @@ class ImagePathDefs:
downloadPath = "/mnt/sd0/startracker" downloadPath = "/mnt/sd0/startracker"
jsonFile = "/mnt/sd0/startracker/test.json" jsonFile = "/mnt/sd0/startracker/test.json"
flashFile = "/mnt/sd0/startracker/flash.bin" flashFile = "/mnt/sd0/startracker/flash.bin"
flashReadPath = "/mnt/sd0/startracker"
class Region:
# Definition according to datasheet (which turned out to be partially faulty)
BOOTLOADER = 0
STAR_TRACKER_FIRMWARE = 1
FREE_1 = 2
FREE_2 = 3
class PartitionSize:
BOOTLOADER = 128000
STAR_TRACKER_FIRMWARE = 896000
FREE_1 = 128000
FREE_2 = 896000
def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT:
@ -250,11 +267,45 @@ def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code
command = pack_write_command(object_id) command = pack_write_command(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=58, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=58, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code == "34":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Read"))
command = pack_read_command(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=59, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "35":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set read filename"))
filename = input("Specify filename: ")
command = object_id + StarTrackerActionIds.SET_READ_FILENAME + bytearray(filename, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=60, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "36":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Get checksum"))
command = pack_checksum_command(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
def pack_write_command(object_id: bytearray) -> bytearray: def pack_write_command(object_id: bytearray) -> bytearray:
region = 1 region = Region.FREE_1
address = 0 address = 0
command = object_id + struct.pack('!I', StarTrackerActionIds.WRITE) + struct.pack('!B', region) + \ command = object_id + struct.pack('!I', StarTrackerActionIds.WRITE) + struct.pack('!B', region) + \
struct.pack('!I', address) + bytearray(ImagePathDefs.flashFile, 'utf-8') struct.pack('!I', address) + bytearray(ImagePathDefs.flashFile, 'utf-8')
return command return command
def pack_read_command(object_id: bytearray) -> bytearray:
region = Region.STAR_TRACKER_FIRMWARE
address = 0
size = PartitionSize.STAR_TRACKER_FIRMWARE
command = object_id + struct.pack('!I', StarTrackerActionIds.READ) + struct.pack('!B', region) + \
struct.pack('!I', address) + struct.pack('!I', size) + bytearray(ImagePathDefs.flashReadPath, 'utf-8')
return command
def pack_checksum_command(object_id: bytearray) -> bytearray:
region = Region.STAR_TRACKER_FIRMWARE
address = 0
size = PartitionSize.STAR_TRACKER_FIRMWARE
command = object_id + struct.pack('!I', StarTrackerActionIds.CHECKSUM) + struct.pack('!B', region) + \
struct.pack('!I', address) + struct.pack('!I', size)
return command

View File

@ -4,6 +4,10 @@ from config.object_ids import *
from pus_tc.imtq import ImtqActionIds from pus_tc.imtq import ImtqActionIds
from pus_tc.ploc_mpsoc import PlocReplyIds from pus_tc.ploc_mpsoc import PlocReplyIds
from pus_tc.ploc_supervisor import SupvActionIds from pus_tc.ploc_supervisor import SupvActionIds
from pus_tc.star_tracker import StarTrackerActionIds
from tmtccmd.utility.logger import get_console_logger
LOGGER = get_console_logger()
def user_analyze_service_8_data( def user_analyze_service_8_data(
@ -35,6 +39,8 @@ def user_analyze_service_8_data(
return handle_ploc_replies(action_id, custom_data) return handle_ploc_replies(action_id, custom_data)
elif object_id == PLOC_SUPV_ID: elif object_id == PLOC_SUPV_ID:
return handle_supervisor_replies(action_id, custom_data) return handle_supervisor_replies(action_id, custom_data)
elif object_id == STAR_TRACKER_ID:
return handle_startracker_replies(action_id, custom_data)
else: else:
header_list = [] header_list = []
content_list = [] content_list = []
@ -68,3 +74,17 @@ def handle_supervisor_replies(action_id: int, custom_data: bytearray) -> Tuple[l
header_list = ['MRAM Dump'] header_list = ['MRAM Dump']
content_list = [custom_data[:len(custom_data)]] content_list = [custom_data[:len(custom_data)]]
return header_list, content_list return header_list, content_list
def handle_startracker_replies(action_id: int, custom_data: bytearray) -> Tuple[list, list]:
header_list = []
content_list = []
if action_id == StarTrackerActionIds.CHECKSUM:
if len(custom_data) != 5:
LOGGER.warning("Star tracker reply has invalid length {0}".format(len(custom_data)))
return header_list, content_list
header_list = ['Checksum', 'Checksum valid']
print(custom_data[4])
checksum_valid_flag = custom_data[4] >> 8
content_list = ['0x' + custom_data[:4].hex(), checksum_valid_flag]
return header_list, content_list