2016-03-05 10:06:28 +00:00
|
|
|
#!/usr/bin/env python
|
2016-03-05 08:01:29 +00:00
|
|
|
#
|
|
|
|
# Test Transmitter Script
|
|
|
|
# Transmit a set of images from the test_images directory
|
|
|
|
#
|
2018-01-25 03:04:43 +00:00
|
|
|
# Copyright (C) 2018 Mark Jessop <vk5qi@rfhead.net>
|
|
|
|
# Released under GNU GPL v3 or later
|
2016-03-05 08:01:29 +00:00
|
|
|
#
|
|
|
|
|
2018-12-23 06:52:10 +00:00
|
|
|
import PacketTX, sys, os, argparse
|
2016-03-05 08:01:29 +00:00
|
|
|
|
|
|
|
# Set to whatever resolution you want to test.
|
2019-07-26 14:00:02 +00:00
|
|
|
file_path = "../test_images/%d_raw.bin" # _raw, _800x608, _640x480, _320x240
|
2022-03-19 03:50:41 +00:00
|
|
|
image_numbers = range(1,14)
|
2016-03-05 08:01:29 +00:00
|
|
|
|
2016-12-05 13:11:53 +00:00
|
|
|
debug_output = False # If True, packet bits are saved to debug.bin as one char per bit.
|
2016-03-05 10:06:28 +00:00
|
|
|
|
2016-03-05 08:01:29 +00:00
|
|
|
def transmit_file(filename, tx_object):
|
|
|
|
file_size = os.path.getsize(filename)
|
|
|
|
|
|
|
|
if file_size % 256 > 0:
|
|
|
|
print("File size not a multiple of 256 bytes!")
|
|
|
|
return
|
|
|
|
|
2022-03-19 03:50:41 +00:00
|
|
|
print("Transmitting %d Packets." % (file_size//256))
|
2016-03-05 08:01:29 +00:00
|
|
|
|
|
|
|
f = open(filename,'rb')
|
|
|
|
|
2022-03-19 03:50:41 +00:00
|
|
|
for x in range(file_size//256):
|
2016-03-05 08:01:29 +00:00
|
|
|
data = f.read(256)
|
|
|
|
tx_object.tx_packet(data)
|
|
|
|
|
|
|
|
f.close()
|
|
|
|
print("Waiting for tx queue to empty...")
|
|
|
|
tx_object.wait()
|
|
|
|
|
|
|
|
|
2018-12-23 06:52:10 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--baudrate", default=115200, type=int, help="Transmitter baud rate. Defaults to 115200 baud.")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
tx = PacketTX.PacketTX(debug=debug_output, serial_baud=args.baudrate)
|
2016-03-05 08:01:29 +00:00
|
|
|
tx.start_tx()
|
2016-03-13 02:08:39 +00:00
|
|
|
print("TX Started. Press Ctrl-C to stop.")
|
|
|
|
try:
|
2016-09-09 13:12:31 +00:00
|
|
|
for img in image_numbers:
|
|
|
|
filename = file_path % img
|
|
|
|
print("\nTXing: %s" % filename)
|
|
|
|
transmit_file(filename,tx)
|
|
|
|
tx.close()
|
2016-03-13 02:08:39 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("Closing...")
|
|
|
|
tx.close()
|