Update fc_block_decode.py save first image block

fc-fctelem
Alan Johnston 10 months ago committed by GitHub
parent 7fa78bb4a3
commit 71a64a116e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -57,25 +57,15 @@ if __name__ == "__main__":
print("Writing payload to file") print("Writing payload to file")
immutable_payload = bytes(bytearray(data_block[(FC_PAYLOAD + extended):])) # payload) immutable_payload = bytes(bytearray(data_block[(FC_PAYLOAD + extended):])) # payload)
print(immutable_payload) print(immutable_payload)
with open("image_file", "ab") as binary_file: with open("image_file_payload", "wb") as binary_file:
binary_file.write(immutable_payload) binary_file.write(immutable_payload)
except: except:
print("File error") print("File error")
# try: # try:
filename = "/home/pi/fctelem/image_file" + str(image_id) + "." + str(image_count) + ".jpeg" filename = "/home/pi/fctelem/image_file" + str(image_id) + "." + str(image_count) + ".jpeg"
system("/home/pi/ssdv/ssdv -d -J /home/pi/fctelem/image_file " + filename + " 2>&1 | tee /home/pi/fctelem/ssdv_output") system("/home/pi/ssdv/ssdv -d -J /home/pi/fctelem/image_file_payload /home/pi/fctelem/image_file_payload.jpeg 2>&1 | tee /home/pi/fctelem/ssdv_output")
# process = subprocess.run(["/home/pi/ssdv/ssdv","-d","-J", "image_file", filename], text=True)
# print("\n\n RESULT: \n")
# print(process)
# print("\n\n process.stdout: \n")
# print(process.stdout)
# s = io.StringIO(process.stdout)
# for line in s:
# print("After ssdv")
# system("cat /home/pi/fctelem/ssdv_output")
with open("/home/pi/fctelem/ssdv_output", "r") as file: with open("/home/pi/fctelem/ssdv_output", "r") as file:
# print("Starting with")
for line in file: for line in file:
# print("line:") # print("line:")
# print(line) # print(line)
@ -90,9 +80,9 @@ if __name__ == "__main__":
print("End of image") print("End of image")
newfilename = "/home/pi/fctelem/image_file" + str(image_id) + ".jpeg" newfilename = "/home/pi/fctelem/image_file" + str(image_id) + ".jpeg"
# system("/home/pi/ssdv/ssdv -d -J /home/pi/fctelem/image_file " + filename) # system("/home/pi/ssdv/ssdv -d -J /home/pi/fctelem/image_file " + filename)
system("sudo cp " + filename + " " + newfilename) system("sudo mv " + filename + " " + newfilename)
system("sudo mv /home/pi/fctelem/image_file /home/pi/fctelem/image_file" + str(image_id)) system("sudo mv /home/pi/fctelem/image_file /home/pi/fctelem/image_file" + str(image_id))
print("Image ID: ") print("New Image ID: ")
print(image_id) print(image_id)
# image_count = (image_count + 1) % 256 # image_count = (image_count + 1) % 256
image_count = 0 image_count = 0
@ -100,7 +90,9 @@ if __name__ == "__main__":
image_count += 1 image_count += 1
print("image_count:") print("image_count:")
print(image_count) print(image_count)
with open("image_file", "ab") as binary_file:
binary_file.write(immutable_payload)
system("/home/pi/ssdv/ssdv -d -J /home/pi/fctelem/image_file " + filename)
system("sudo cp " + filename + " /home/pi/CubeSatSim/groundstation/public_html/image_file.jpeg") system("sudo cp " + filename + " /home/pi/CubeSatSim/groundstation/public_html/image_file.jpeg")
# image = Image.open("image_file" + str(image_count) + "." + str(image_index) + ".jpeg") # image = Image.open("image_file" + str(image_count) + "." + str(image_index) + ".jpeg")
# image.show() # image.show()

Loading…
Cancel
Save

Powered by TurnKey Linux.