Merge remote-tracking branch 'origin/develop' into mueller/master

This commit is contained in:
Robin Müller 2022-01-02 16:31:39 +01:00
commit a5bc7ec06e
5 changed files with 178 additions and 10 deletions

View File

@ -310,13 +310,26 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
"24": ("Star Tracker: Validation", {OpCodeDictKeys.TIMEOUT: 2.0}),
"25": ("Star Tracker: Algo", {OpCodeDictKeys.TIMEOUT: 2.0}),
"26": ("Star Tracker: Take image", {OpCodeDictKeys.TIMEOUT: 2.0}),
"27": ("Star Tracker: Stop image loader", {OpCodeDictKeys.TIMEOUT: 2.0}),
"27": ("Star Tracker: Stop str helper", {OpCodeDictKeys.TIMEOUT: 2.0}),
"28": ("Star Tracker: Reset error signal", {OpCodeDictKeys.TIMEOUT: 2.0}),
"29": ("Star Tracker: Set name of download image", {OpCodeDictKeys.TIMEOUT: 2.0}),
"30": ("Star Tracker: Request histogram", {OpCodeDictKeys.TIMEOUT: 2.0}),
"31": ("Star Tracker: Request contrast", {OpCodeDictKeys.TIMEOUT: 2.0}),
"32": ("Star Tracker: Set json filename", {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}),
"37": ("Star Tracker: Set time", {OpCodeDictKeys.TIMEOUT: 2.0}),
"38": ("Star Tracker: Download centroid", {OpCodeDictKeys.TIMEOUT: 2.0}),
"39": ("Star Tracker: Upload centroid (not implemented by arcsec?)", {OpCodeDictKeys.TIMEOUT: 2.0}),
"40": ("Star Tracker: Download matched star", {OpCodeDictKeys.TIMEOUT: 2.0}),
"41": ("Star Tracker: Download DB Image", {OpCodeDictKeys.TIMEOUT: 2.0}),
"42": ("Star Tracker: Download Blob Pixel", {OpCodeDictKeys.TIMEOUT: 2.0}),
"43": ("Star Tracker: Download FPGA Image", {OpCodeDictKeys.TIMEOUT: 2.0}),
"44": ("Star Tracker: Change download FPGA image name", {OpCodeDictKeys.TIMEOUT: 2.0}),
"45": ("Star Tracker: Upload FPGA image", {OpCodeDictKeys.TIMEOUT: 2.0}),
"46": ("Star Tracker: FPGA action", {OpCodeDictKeys.TIMEOUT: 2.0}),
}
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",
RAD_SENSOR_ID: "Radiation Sensor",
PLOC_SUPV_ID: "PLOC Supervisor",
PLOC_MPSOC_ID: "PLOC MPSoC",
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

View File

@ -20,10 +20,13 @@ class StarTrackerActionIds:
REQ_VERSION = 2
REQ_INTERFACE = 3
REQ_TIME = 4
REQ_POWER = 11
SWITCH_TO_BOOTLOADER_PROGRAM = 7
REQ_POWER = 11
TAKE_IMAGE = 15
DOWNLOAD_IMAGE = 9
UPLOAD_IMAGE = 10
DOWNLOAD_CENTROID = 16
UPLOAD_CENTROID = 17
SUBSCRIBE_TO_TM = 18
REQ_SOLUTION = 24
REQ_TEMPERATURE = 25
@ -40,13 +43,21 @@ class StarTrackerActionIds:
VALIDATION = 48
ALGO = 49
CHECKSUM = 50
RAED = 51
READ = 51
WRITE = 52
TAKE_IMAGE = 15
STOP_IMAGE_LOADER = 55
DOWNLOAD_MATCHED_STAR = 53
STOP_STR_HELPER = 55
RESET_ERROR = 56
CHANGE_DOWNLOAD_IMAGE = 57
SET_JSON_FILE_NAME = 58
SET_READ_FILENAME = 59
SET_TIME = 60
DOWNLOAD_DBIMAGE = 61
DOWNLOAD_BLOBPIXEL = 62
DOWNLOAD_FPGA_IMAGE = 63
CHANGE_FPGA_DOWNLOAD_FILE = 64
UPLOAD_FPGA_IMAGE = 65
FPGA_ACTION = 66
class ImagePathDefs:
@ -55,6 +66,26 @@ class ImagePathDefs:
downloadPath = "/mnt/sd0/startracker"
jsonFile = "/mnt/sd0/startracker/test.json"
flashFile = "/mnt/sd0/startracker/flash.bin"
flashReadPath = "/mnt/sd0/startracker"
uploadCentroidJson = "/mnt/sd0/startracker/upload-centroid.json"
downloadFpgaImagePath = "/mnt/sd0/startracker"
downloadFpgaImageName = "testname"
uploadFpgaImageName = "/mnt/sd0/startracker/fpga-image.bin"
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:
@ -213,8 +244,8 @@ def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code
command = PusTelecommand(service=8, subservice=128, ssc=52, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "27":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Stop image loader"))
command = object_id + struct.pack('!I', StarTrackerActionIds.STOP_IMAGE_LOADER)
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Stop str helper"))
command = object_id + struct.pack('!I', StarTrackerActionIds.STOP_STR_HELPER)
command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "28":
@ -250,11 +281,112 @@ def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code
command = pack_write_command(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=58, app_data=command)
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())
if op_code == "37":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set time"))
unix_time = 1640783543
command = object_id + struct.pack('!I', StarTrackerActionIds.SET_TIME) + struct.pack('!Q', unix_time)
command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "38":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Centroid"))
id = 0
command = object_id + struct.pack('!I', StarTrackerActionIds.DOWNLOAD_CENTROID) + struct.pack('!B', id)
command = PusTelecommand(service=8, subservice=128, ssc=62, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "39":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload Centroid"))
command = object_id + struct.pack('!I', StarTrackerActionIds.UPLOAD_CENTROID) + \
bytearray(ImagePathDefs.uploadCentroidJson, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "40":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download matched star"))
id = 0
command = object_id + struct.pack('!I', StarTrackerActionIds.DOWNLOAD_MATCHED_STAR) + \
struct.pack('!B', id)
command = PusTelecommand(service=8, subservice=128, ssc=64, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "41":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download DB Image"))
id = 0
command = object_id + struct.pack('!I', StarTrackerActionIds.DOWNLOAD_DBIMAGE) + \
struct.pack('!B', id)
command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "42":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Blob Pixel"))
id = 0
type = 1 # 0 - normal, 1 - fast
command = object_id + struct.pack('!I', StarTrackerActionIds.DOWNLOAD_BLOBPIXEL) + \
struct.pack('!B', id) + struct.pack('!B', type)
command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "43":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download FPGA Image"))
position = 0
length = 4100
command = object_id + struct.pack('!I', StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) + \
struct.pack('!I', position) + struct.pack('!I', length) + bytearray(
ImagePathDefs.downloadFpgaImagePath, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=66, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "44":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Chnage donwload FPGA image file name"))
command = object_id + struct.pack('!I', StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) + \
bytearray(ImagePathDefs.downloadFpgaImageName, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=67, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "45":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload FPGA image"))
command = object_id + struct.pack('!I', StarTrackerActionIds.UPLOAD_FPGA_IMAGE) + \
bytearray(ImagePathDefs.uploadFpgaImageName, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=68, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "46":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: FPGA action"))
id = 3
command = object_id + struct.pack('!I', StarTrackerActionIds.FPGA_ACTION) + struct.pack('!B', id)
command = PusTelecommand(service=8, subservice=128, ssc=69, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
def pack_write_command(object_id: bytearray) -> bytearray:
region = 1
region = Region.FREE_1
address = 0
command = object_id + struct.pack('!I', StarTrackerActionIds.WRITE) + struct.pack('!B', region) + \
struct.pack('!I', address) + bytearray(ImagePathDefs.flashFile, 'utf-8')
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.ploc_mpsoc import PlocReplyIds
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(
@ -35,6 +39,8 @@ def user_analyze_service_8_data(
return handle_ploc_replies(action_id, custom_data)
elif object_id == PLOC_SUPV_ID:
return handle_supervisor_replies(action_id, custom_data)
elif object_id == STAR_TRACKER_ID:
return handle_startracker_replies(action_id, custom_data)
else:
header_list = []
content_list = []
@ -68,3 +74,17 @@ def handle_supervisor_replies(action_id: int, custom_data: bytearray) -> Tuple[l
header_list = ['MRAM Dump']
content_list = [custom_data[:len(custom_data)]]
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

@ -1 +1 @@
Subproject commit bfa459ccc3c7189a77374a68f0217d448525b34b
Subproject commit 5fdeec29ee878a3daa4bee5e3f36a39be3b70b31