Added LDPC encoding option to PacketTX. tx_picam now saves TXed images.

pull/1/head
Mark Jessop 2016-04-04 09:19:14 +08:00
rodzic 6b51690aba
commit c2e41f775c
3 zmienionych plików z 12 dodań i 5 usunięć

Wyświetl plik

@ -13,6 +13,7 @@ import serial,Queue,sys,crcmod,struct
from time import sleep
from threading import Thread
import numpy as np
from ldpc_encoder import *
# Alternate output module, which writes transmitted data as one-bit-per-char (i.e. 0 = 0x00, 1 = 0x01)
# to a file. Very useful for debugging.
@ -43,7 +44,7 @@ class PacketTX(object):
idle_sequence = "\x55"*256
def __init__(self,serial_port="/dev/ttyAMA0", serial_baud=115200, payload_length=256, debug = False):
def __init__(self,serial_port="/dev/ttyAMA0", serial_baud=115200, payload_length=256, fec=False, debug = False):
# WARNING: 115200 baud is ACTUALLY 115386.834 baud, as measured using a freq counter.
if debug == True:
self.s = BinaryDebug()
@ -53,6 +54,7 @@ class PacketTX(object):
self.payload_length = payload_length
self.crc16 = crcmod.predefined.mkCrcFun('crc-ccitt-false')
self.fec = fec
def start_tx(self):
self.transmit_active = True
@ -68,7 +70,11 @@ class PacketTX(object):
packet = packet + "\x00"*(self.payload_length - len(packet))
crc = struct.pack("<H",self.crc16(packet))
return self.preamble + self.unique_word + packet + crc
if self.fec:
return self.preamble + self.unique_word + packet + crc + ldpc_encode_string(packet+crc)
else:
return self.preamble + self.unique_word + packet + crc
def tx_thread(self):

Wyświetl plik

@ -6,7 +6,7 @@
# Mark Jessop <vk5qi@rfhead.net>
#
import PacketTX, sys, os
import PacketTX, sys, os, datetime
# Set to whatever resolution you want to transmit.
tx_resolution = "1024x768"
@ -44,12 +44,13 @@ try:
while True:
# Capture image using PiCam
print("Capturing Image...")
os.system("raspistill -t 100 -o temp.jpg -vf -hf -w 1024 -h 768")
capture_time = datetime.datetime.utcnow().strftime("%Y%m%d-%H%M%SZ")
os.system("raspistill -t 100 -o ./tx_images/%s.jpg -vf -hf -w 1024 -h 768" % capture_time)
# Resize using convert
print("Processing...")
#os.system("convert temp.jpg -resize %s\! temp.jpg" % tx_resolution)
# SSDV'ify the image.
os.system("ssdv -e -c %s -i %d temp.jpg temp.ssdv" % (callsign,image_id))
os.system("ssdv -e -c %s -i %d ./tx_images/%s.jpg temp.ssdv" % (callsign,image_id,capture_time))
# Transmit image
print("Transmitting...")
transmit_file("temp.ssdv",tx)