kopia lustrzana https://github.com/projecthorus/wenet
Added LDPC encoding option to PacketTX. tx_picam now saves TXed images.
rodzic
6b51690aba
commit
c2e41f775c
10
PacketTX.py
10
PacketTX.py
|
@ -13,6 +13,7 @@ import serial,Queue,sys,crcmod,struct
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import numpy as np
|
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)
|
# 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.
|
# to a file. Very useful for debugging.
|
||||||
|
@ -43,7 +44,7 @@ class PacketTX(object):
|
||||||
idle_sequence = "\x55"*256
|
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.
|
# WARNING: 115200 baud is ACTUALLY 115386.834 baud, as measured using a freq counter.
|
||||||
if debug == True:
|
if debug == True:
|
||||||
self.s = BinaryDebug()
|
self.s = BinaryDebug()
|
||||||
|
@ -53,6 +54,7 @@ class PacketTX(object):
|
||||||
self.payload_length = payload_length
|
self.payload_length = payload_length
|
||||||
|
|
||||||
self.crc16 = crcmod.predefined.mkCrcFun('crc-ccitt-false')
|
self.crc16 = crcmod.predefined.mkCrcFun('crc-ccitt-false')
|
||||||
|
self.fec = fec
|
||||||
|
|
||||||
def start_tx(self):
|
def start_tx(self):
|
||||||
self.transmit_active = True
|
self.transmit_active = True
|
||||||
|
@ -68,7 +70,11 @@ class PacketTX(object):
|
||||||
packet = packet + "\x00"*(self.payload_length - len(packet))
|
packet = packet + "\x00"*(self.payload_length - len(packet))
|
||||||
|
|
||||||
crc = struct.pack("<H",self.crc16(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):
|
def tx_thread(self):
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# Mark Jessop <vk5qi@rfhead.net>
|
# Mark Jessop <vk5qi@rfhead.net>
|
||||||
#
|
#
|
||||||
|
|
||||||
import PacketTX, sys, os
|
import PacketTX, sys, os, datetime
|
||||||
|
|
||||||
# Set to whatever resolution you want to transmit.
|
# Set to whatever resolution you want to transmit.
|
||||||
tx_resolution = "1024x768"
|
tx_resolution = "1024x768"
|
||||||
|
@ -44,12 +44,13 @@ try:
|
||||||
while True:
|
while True:
|
||||||
# Capture image using PiCam
|
# Capture image using PiCam
|
||||||
print("Capturing Image...")
|
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
|
# Resize using convert
|
||||||
print("Processing...")
|
print("Processing...")
|
||||||
#os.system("convert temp.jpg -resize %s\! temp.jpg" % tx_resolution)
|
#os.system("convert temp.jpg -resize %s\! temp.jpg" % tx_resolution)
|
||||||
# SSDV'ify the image.
|
# 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
|
# Transmit image
|
||||||
print("Transmitting...")
|
print("Transmitting...")
|
||||||
transmit_file("temp.ssdv",tx)
|
transmit_file("temp.ssdv",tx)
|
||||||
|
|
Ładowanie…
Reference in New Issue