Skip to content
Snippets Groups Projects
Commit 3949ead6 authored by Robin Mueller's avatar Robin Mueller
Browse files

lock/unlock file bugfixes

parent 8b30ed95
No related branches found
No related tags found
No related merge requests found
......@@ -435,7 +435,7 @@ def generate_read_file_srv23_140_packet(
return PusTelecommand(service=23, subservice=140, ssc=ssc, app_data=data_to_pack)
def generate_lock_file_packet(ssc: int, repository_path: str, filename: str,
def generate_lock_file_packet(ssc: int, lock: bool, repository_path: str, filename: str,
object_id: bytearray = g.SD_CARD_HANDLER_ID):
data_to_pack = bytearray(object_id)
data_to_pack += repository_path.encode('utf-8')
......@@ -444,7 +444,10 @@ def generate_lock_file_packet(ssc: int, repository_path: str, filename: str,
data_to_pack += filename.encode('utf-8')
# Add string terminator of filename
data_to_pack.append(0)
return PusTelecommand(service=23, subservice=5, ssc=ssc, app_data=data_to_pack)
if lock:
return PusTelecommand(service=23, subservice=5, ssc=ssc, app_data=data_to_pack)
else:
return PusTelecommand(service=23, subservice=6, ssc=ssc, app_data=data_to_pack)
def pack_service23_commands_into(tc_queue: Deque, op_code: int) -> Deque:
......@@ -514,8 +517,8 @@ def pack_service23_commands_into(tc_queue: Deque, op_code: int) -> Deque:
generate_generic_folder_structure(tc_queue, init_ssc=0, iobc=True)
elif op_code == "5" or op_code == 5:
LOGGER.info("Press h in the following input requests to send a command to display the"
"folder sturcture instead")
LOGGER.info("Press h in the following input requests")
LOGGER.info("to send a command to display the folder sturcture instead")
(repo_path, filename) = prompt_for_repo_filename()
if repo_path == "" and filename == "h":
tc_queue.append(("print", "Printing active file system"))
......@@ -524,7 +527,8 @@ def pack_service23_commands_into(tc_queue: Deque, op_code: int) -> Deque:
return tc_queue
else:
tc_queue.append(("print", "Locking file"))
command = generate_lock_file_packet(0, repository_path=repo_path, filename=filename)
command = generate_lock_file_packet(0, repository_path=repo_path, filename=filename,
lock=True)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "6" or op_code == 6:
......@@ -538,7 +542,8 @@ def pack_service23_commands_into(tc_queue: Deque, op_code: int) -> Deque:
return tc_queue
else:
tc_queue.append(("print", "Unlocking file"))
command = generate_lock_file_packet(0, repository_path=repo_path, filename=filename)
command = generate_lock_file_packet(0, repository_path=repo_path, filename=filename,
lock=False)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
......
......@@ -11,7 +11,8 @@ class Service23TM(PusTelemetry):
self.filename = ""
self.data_start_idx = 0
if self.get_subservice() == 132:
self.unpack_repo_and_filename()
# self.unpack_repo_and_filename()
pass
def unpack_repo_and_filename(self):
repo_path_found = False
......
......@@ -64,7 +64,7 @@ def perform_file_upload(com_if: CommunicationInterface, tmtc_printer: TmTcPrinte
else:
selection = input("Invalid input, try again [c to cancel]: ")
print_string = file_path.rsplit('/', 1)[-1] + " was selected."
print_string = file_path.rsplit(os.path.sep, 1)[-1] + " was selected."
LOGGER.info(print_string)
calc_hamming_code = input("Calculate and send hamming code? [y/n]: ")
if calc_hamming_code in ['y', 'yes', 1]:
......@@ -175,7 +175,8 @@ def perform_file_upload(com_if: CommunicationInterface, tmtc_printer: TmTcPrinte
for tm_list in reception_deque:
for tm_packet in tm_list:
if tm_packet.get_service() == 23 and tm_packet.get_subservice() == 132:
tmtc_printer.print_telemetry(tm_packet)
# tmtc_printer.print_telemetry(tm_packet)
pass
tm_listener.clear_tm_packet_queue()
LOGGER.info("Transitioning back to listener mode..")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment