Something went wrong on our end
Forked from an inaccessible project.
-
Robin.Mueller authoredRobin.Mueller authored
obsw_binary_uploader.py 2.10 KiB
#!/usr/bin/python3.8
"""
@brief Binary Uploader Module
@details
This module will be used to upload binaries to the OBC via a communication port, given
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 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(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]: ")
if calc_hamming_code in ['y', 'yes', 1]:
calc_hamming_code = True
print("Hamming code will be calculated and sent in tail packet")
else:
calc_hamming_code = False
print("Hamming code will not be calculated")
# Right now, the size of PUS packets is limited to 1500 bytes. Therefore, we split up the
# binary.
frame_length = g.G_MAX_BINARY_FRAME_LENGTH
if calc_hamming_code:
# 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()
# Delete existing binary file first, otherwise data might be appeneded to otherwise
# valid file which already exists.
# generate_service23_subservice1_packet()
# We have to split the binary here first
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(2.0)
print("Test2")