Various fixes from system testing...

pull/1/head
Mark Jessop 2017-01-06 21:33:30 +10:30
rodzic 6e3f8ac5f4
commit 9b1f5a78f7
4 zmienionych plików z 42 dodań i 8 usunięć

Wyświetl plik

@ -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()

Wyświetl plik

@ -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.

Wyświetl plik

@ -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

Wyświetl plik

@ -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,