diff --git a/rx/telemetry_console.py b/rx/telemetry_console.py index 48cba25..80c4317 100644 --- a/rx/telemetry_console.py +++ b/rx/telemetry_console.py @@ -11,6 +11,8 @@ import datetime import traceback from WenetPackets import * +log_file = open('telemetry.log', 'a') + def process_udp(udp_packet): """ Process received UDP packets. """ # Grab timestamp. @@ -21,7 +23,11 @@ def process_udp(udp_packet): packet = packet_dict['packet'] # Convert to string, and print to terminal with timestamp. - print("%s \t%s" % (timestamp,packet_to_string(packet))) + telem_string = "%s \t%s" % (timestamp,packet_to_string(packet)) + + print(telem_string) + log_file.write(telem_string + "\n") + log_file.flush() diff --git a/tx/BNO055.py b/tx/BNO055.py index 04747f5..e9e890f 100644 --- a/tx/BNO055.py +++ b/tx/BNO055.py @@ -801,7 +801,6 @@ class WenetBNO055(object): self.log_file = None self.bno = None - self.init() # Start RX thead. self.rx_thread = Thread(target=self.rx_loop) @@ -810,7 +809,7 @@ class WenetBNO055(object): def init(self, reset=True): while self.bno == None: try: - self.bno = BNO055(serial_port=port) + self.bno = BNO055(serial_port=self.port) success = self.bno.begin(reset=reset) if success: self.debug_message("Connected to BNO055!") @@ -890,6 +889,9 @@ class WenetBNO055(object): def rx_loop(self): """ Main BNO055 polling loop. """ + # Initialise BNO055 + self.init() + while self.rx_running: try: # Grab a complete set of data from the BNO055 @@ -943,7 +945,6 @@ class WenetBNO055(object): # Clear write locks. self.state_blockwrite = False self.state_writelock = False - print(time.time()-start) if self.rx_counter % self.callback_decimation == 0: # Send data to the callback function. diff --git a/tx/PacketTX.py b/tx/PacketTX.py index 77f1159..a9c4f56 100644 --- a/tx/PacketTX.py +++ b/tx/PacketTX.py @@ -18,6 +18,7 @@ import serial import Queue import sys import os +import datetime import crcmod import struct import traceback @@ -69,7 +70,14 @@ class PacketTX(object): text_message_count = 0 # WARNING: 115200 baud is ACTUALLY 115386.834 baud, as measured using a freq counter. - def __init__(self,serial_port="/dev/ttyAMA0", serial_baud=115200, payload_length=256, fec=True, debug = False, callsign="N0CALL"): + def __init__(self, + serial_port="/dev/ttyAMA0", + serial_baud=115200, + payload_length=256, + fec=True, + debug = False, + callsign="N0CALL", + log_file = None): # Instantiate our low-level transmit interface, be it a serial port, or the BinaryDebug class. if debug == True: @@ -88,6 +96,11 @@ class PacketTX(object): self.idle_message = self.frame_packet(self.idle_sequence,fec=fec) + if log_file != None: + self.log_file = open(log_file,'a') + else: + self.log_file = None + def start_tx(self): self.transmit_active = True txthread = Thread(target=self.tx_thread) @@ -214,7 +227,13 @@ class PacketTX(object): packet = "\x00" + struct.pack(">BH",len(message),self.text_message_count) + message self.queue_telemetry_packet(packet, repeats=repeats) - print("TXing Text Message #%d: %s" % (self.text_message_count,message)) + log_string = "TXing Text Message #%d: %s" % (self.text_message_count,message) + + if self.log_file != None: + self.log_file.write(datetime.datetime.now().isoformat() + "," + log_string + "\n") + + print(log_string) + def transmit_gps_telemetry(self, gps_data): """ Generate and Transmit a GPS Telemetry Packet. @@ -274,6 +293,8 @@ class PacketTX(object): # SHSSP Code goes here... + self.transmit_text_message("Orientation Telemetry Not Implemented.") + return def transmit_image_telemetry(self, gps_data, orientation_data, image_id): @@ -298,7 +319,7 @@ class PacketTX(object): """ # SHSSP Code goes here... - + self.transmit_text_message("Image Telemetry Not Implemented.") return diff --git a/tx/tx_picam_gps.py b/tx/tx_picam_gps.py index b108ae3..7af52c1 100644 --- a/tx/tx_picam_gps.py +++ b/tx/tx_picam_gps.py @@ -108,7 +108,13 @@ def post_process_image(filename): # Finally, initialise the PiCam capture object. -picam = WenetPiCam.WenetPiCam(resolution=(1920,1088), callsign=callsign, num_images=5, debug_ptr=tx.transmit_text_message, vertical_flip=False, horizontal_flip=False) +picam = WenetPiCam.WenetPiCam(src_resolution=(1920,1088), + tx_resolution=(1920,1088), + callsign=callsign, + num_images=5, + debug_ptr=tx.transmit_text_message, + vertical_flip=False, + horizontal_flip=False) # .. and start it capturing continuously. picam.run(destination_directory="./tx_images/", tx = tx,