From 2f40045d27f306e6867b01acf2fea695827b9c4a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 7 Feb 2025 16:41:42 -0500 Subject: [PATCH] Update fc_block_decode.py parse image ID --- groundstation/fc_block_decode.py | 40 ++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/groundstation/fc_block_decode.py b/groundstation/fc_block_decode.py index 9bca6879..66712a48 100644 --- a/groundstation/fc_block_decode.py +++ b/groundstation/fc_block_decode.py @@ -64,27 +64,37 @@ if __name__ == "__main__": # try: filename = "image_file" + str(image_count) + "." + str(image_index) + ".jpeg" # system("/home/pi/ssdv/ssdv -d -J image_file " + filename) - process = subprocess.run(["/home/pi/ssdv/ssdv","-d","-J", "image_file", filename], text=True) + process_output = subprocess.run(["/home/pi/ssdv/ssdv","-d","-J", "image_file", filename], text=True) print("\n\n RESULT: \n") - print(process) + print(process_output) + + for line in process_output: + if ((line.find("Image ID:")) > 0): + print("\nImage ID found!\n") + image_id_string = line.split() + print(image_id_string) + new_image_count = int(image_id_string[1]) + if (new_image_count != image_count): + image_count = new_image_coount + print("End of image") + filename = "image_file" + str(image_count) + ".jpeg" + system("/home/pi/ssdv/ssdv -d -J image_file " + filename) + system("sudo cp " + filename + " /home/pi/CubeSatSim/groundstation/public_html/image_file.jpeg") + system("sudo mv image_file image_file" + str(image_count)) + print("Image count: ") + print(image_count) +# image_count = (image_count + 1) % 256 + image_index = 0 + else: + image_index += 1 + 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.show() # except: # print("Image display error") - image_index += 1 + else: - print("End of image") - filename = "image_file" + str(image_count) + ".jpeg" - system("/home/pi/ssdv/ssdv -d -J image_file " + filename) - system("sudo cp " + filename + " /home/pi/CubeSatSim/groundstation/public_html/image_file.jpeg") -# image = Image.open("image_file" + str(image_count) + ".jpeg") -# image.show() -# system("sudo rm image_file") - system("sudo mv image_file image_file" + str(image_count)) - print("Image count: ") - print(image_count) - image_count = (image_count + 1) % 256 - image_index = 0 + print("Payload not an image!") else: print("Unknown Sat Id or Frame")