diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index d97dc3586a4c4345c9312a4803f0d644d7077a85..a84a19e1ba23bf566166ade3ae055f3fcdf85ec5 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -203,7 +203,7 @@ class TmTcHandler: elif self.mode == g.ModeList.BinaryUploadMode: # Upload binary, prompt user for input, in the end prompt for new mode and enter that # mode - perform_binary_upload() + perform_binary_upload(self.communication_interface) self.command_received = True self.mode = g.ModeList.ListenerMode diff --git a/tc/obsw_tc_service23.py b/tc/obsw_tc_service23.py index 3013a88f5e521ec5a166be2c5c103054155ce8c4..31d705fe3f8dfde22199079140a1c8ec4fe7f9c4 100644 --- a/tc/obsw_tc_service23.py +++ b/tc/obsw_tc_service23.py @@ -71,8 +71,8 @@ def generate_service23_subservice10_packet(directory_name: str, repository_path: def generate_service23_subservice128_packet( tc_queue: Deque, repository_path: str, filename: str, max_size_of_app_data: int, - object_id: bytearray = g.SD_CARD_HANDLER_ID, file_data: bytearray = bytearray([]), - init_ssc: int = 0): + file_data: bytearray = bytearray([]), init_ssc: int = 0, + object_id: bytearray = g.SD_CARD_HANDLER_ID): """ This function generates PUS packets with service 23 and subservie 128 and packs the into the supplied deque container. @@ -87,9 +87,9 @@ def generate_service23_subservice128_packet( @param repository_path: The path of the target file @param filename: Name of file from which the content shall be read @param max_size_of_app_data: Maximum size of one data block. The file - @param object_id: object ID of the memory handler (e.g. SD Card Handler) @param file_data: The data to write in the file @param init_ssc: First SSC, which will be incremented for each packet. + @param object_id: object ID of the memory handler (e.g. SD Card Handler) """ data_to_pack = object_id data_to_pack += bytearray(repository_path, 'utf-8') diff --git a/utility/obsw_args_parser.py b/utility/obsw_args_parser.py index bef39878d7c7eb07d7c2766e11bb4d11da000167..eaacb7db4f80331a97fc9460325a26716cfc64ed 100644 --- a/utility/obsw_args_parser.py +++ b/utility/obsw_args_parser.py @@ -18,9 +18,9 @@ def parse_input_arguments(): arg_parser = argparse.ArgumentParser(description="TMTC Client Command Line Interface") arg_parser.add_argument( - '-m', '--mode', type=int, help='Target Mode. Default is 1(Listener Mode), ' - '0: GUI Mode, 1:Listener Mode, 2: Single Command Mode, 3: Service Test Mode, ' - '4: Software Test Mode, 5: Unit Test Mode ', default=0) + '-m', '--mode', type=int, help='Target Mode. Default is 1 (Listener Mode), ' + '0: GUI Mode, 1: Listener Mode, 2: Single Command Mode, 3: Service Test Mode, ' + '4: Software Test Mode, 5: Binary Upload Mode, 6: Unit Test Mode ', default=0) arg_parser.add_argument( '-c', '--com_if', type=int, help='Communication Interface. 0: Dummy Interface, 1: Serial, ' '2: QEMU, 3: UDP', default=2) diff --git a/utility/obsw_binary_uploader.py b/utility/obsw_binary_uploader.py index a3dbe97772f8af3427e34552397c1b9aafed3dc0..47078d12746fcbcfffc089ec93adfb4089b835e3 100644 --- a/utility/obsw_binary_uploader.py +++ b/utility/obsw_binary_uploader.py @@ -6,20 +6,24 @@ This module will be used to upload binaries to the OBC via a communication port, a supplied binary. The binary will be sent via the specified communication interface. It will be possible to encode the data (for example using DLE encoding) """ +import time import tkinter as tk from tkinter import filedialog -from tc.obsw_tc_service23 import split_large_file +from collections import deque + +from tmtc_core.comIF.obsw_com_interface import CommunicationInterface +from tc.obsw_tc_service23 import generate_service23_subservice128_packet import config.obsw_config as g -def perform_binary_upload(): +def perform_binary_upload(comIF: CommunicationInterface): print("Please select file to upload") root = tk.Tk() root.withdraw() root.wm_attributes('-topmost', 1) file_path = filedialog.askopenfilename(parent=root) print("File select: " + str(file_path)) - calc_hamming_code = input("Calculate and send hamming code? [y/n]") + calc_hamming_code = input("Calculate and send hamming code? [y/n]: ") if calc_hamming_code in ['y', 'yes', 1]: calc_hamming_code = True print("Hamming code will be calculated and sent in tail packet") @@ -35,5 +39,17 @@ def perform_binary_upload(): # now we calculate the hamming code pass + # Read file as binary file + with open(file_path, 'rb') as file: + data_to_read = bytearray(file.read()) + + print("Test") + tc_queue = deque() # We have to split the binary here first - split_large_file() + generate_service23_subservice128_packet(tc_queue, "BIN/AT91/BL", "bl.bin", 1024, data_to_read) + while tc_queue: + (tc_packet, tc_info) = tc_queue.pop() + comIF.send_telecommand(tc_packet, tc_info) + print("Sending..") + time.sleep(0.5) + print("Test2")