Merge pull request #14 from ke5gdb/master

Add Chasemapper / UDP Payload Summary emitter
pull/16/head
Mark Jessop 2024-09-07 20:24:41 +09:30 zatwierdzone przez GitHub
commit 9959be4ccb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 78 dodań i 4 usunięć

Wyświetl plik

@ -23,13 +23,18 @@ fi
: "${BIAS:=0}"
: "${BAUD_RATE:=115177}"
: "${OVERSAMPLING:=8}"
: "${UDP_PORT:=0}"
# Start up the SSDV Uploader script and push it into the background.
python3 ssdvuploader.py "$MYCALL" &
SSDV_UPLOAD_PID=$!
# Start the Web Interface Server
python3 wenetserver.py "$MYCALL" &
if [ "$UDP_PORT" = "0" ]; then
python3 wenetserver.py "$MYCALL" &
else
python3 wenetserver.py "$MYCALL" -u "$UDP_PORT" &
fi
WEB_VIEWER_PID=$!
# Calculate the SDR sample rate required.

Wyświetl plik

@ -41,6 +41,9 @@ socketio = SocketIO(app)
# PySondeHub Uploader, instantiated later.
sondehub = None
# UDP port for Payload Summary emit
udp_emit_port = 0
# Latest Image
latest_image = None
latest_image_lock = Lock()
@ -127,7 +130,7 @@ def handle_gps_telemetry(gps_data):
logging.debug("No GPS lock - discarding GPS telemetry.")
return
if sondehub:
# Add to the SondeHub-Amateur uploader!
sondehub.add_telemetry(
@ -147,9 +150,63 @@ def handle_gps_telemetry(gps_data):
snr = round(current_modem_stats['snr'],1)
)
# TODO - Emit as a Horus UDP Payload Summary packet.
# Emit as a Horus UDP Payload Summary packet.
if udp_emit_port > 0:
try:
# Prepare heading & speed fields, if they are provided in the incoming telemetry blob.
# Generate 'short' time field.
_short_time = gps_data['timestamp'].split('T')[1] + 'Z'
packet = {
"type": "PAYLOAD_SUMMARY",
"station": my_callsign,
"callsign": current_callsign + "-Wenet",
"latitude": round(gps_data['latitude'],6),
"longitude": round(gps_data['longitude'],6),
"altitude": round(gps_data['altitude'],1),
"sats": gps_data['numSV'],
"speed": round(gps_data['ground_speed'],1),
"heading": round(gps_data['heading'],1),
"time": _short_time,
"frequency": round(current_modem_stats['fcentre']/1e6, 5),
"snr": round(current_modem_stats['snr'],1),
"comment": "Wenet",
}
# Set up our UDP socket
_s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
_s.settimeout(1)
# Set up socket for broadcast, and allow re-use of the address
_s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Under OSX we also need to set SO_REUSEPORT to 1
try:
_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except:
pass
try:
_s.sendto(
json.dumps(packet).encode("ascii"),
("<broadcast>", udp_emit_port),
)
# Catch any socket errors, that may occur when attempting to send to a broadcast address
# when there is no network connected. In this case, re-try and send to localhost instead.
except socket.error as e:
logging.debug(
"Send to broadcast address failed, sending to localhost instead."
)
_s.sendto(
json.dumps(packet).encode("ascii"),
("127.0.0.1", udp_emit_port),
)
_s.close()
except Exception as e:
logging.error("Error sending Payload Summary: %s" % str(e))
def handle_telemetry(packet):
""" Handle GPS and Text message packets from the wenet receiver """
@ -256,9 +313,10 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("callsign", help="SondeHub-Amateur Uploader Callsign")
parser.add_argument("-l", "--listen_port",default=5003,help="Port to run Web Server on. (Default: 5003)")
parser.add_argument("-l", "--listen_port", default=5003, help="Port to run Web Server on. (Default: 5003)")
parser.add_argument("-v", "--verbose", action='store_true', help="Enable debug output.")
parser.add_argument("--no_sondehub", action='store_true', help="Disable SondeHub-Amateur position upload.")
parser.add_argument("-u", "--udp_port", default=None, type=int, help="Port to emit Horus UDP packets on. (Default: 0 (disabled), Typical: 55673)")
args = parser.parse_args()
@ -275,6 +333,9 @@ if __name__ == "__main__":
if not args.no_sondehub:
sondehub = Uploader(my_callsign, software_name="pysondehub-wenet", software_version=WENET_VERSION)
if args.udp_port:
udp_emit_port = args.udp_port
logging.getLogger("werkzeug").setLevel(logging.ERROR)
logging.getLogger("socketio").setLevel(logging.ERROR)
logging.getLogger("engineio").setLevel(logging.ERROR)

Wyświetl plik

@ -42,6 +42,13 @@ BAUD_RATE=115177
OVERSAMPLING=8
# UDP Payload Summary
# Default: 0 (disabled)
# Set this to a valid UDP port (55673 typically) to emit payload summary packets for use
# with Chasemapper
UDP_PORT=0
# Stop and remove any existing wenet instances
echo "Stopping/Removing any existing Wenet instances..."
docker stop wenet || true && docker rm wenet || true
@ -57,6 +64,7 @@ docker run -d \
-e BAUD_RATE=$BAUD_RATE \
-e OVERSAMPLING=$OVERSAMPLING \
-e DEVICE=$DEVICE \
-e UDP_PORT=$UDP_PORT \
-v ~/wenet/rx_images/:/opt/wenet/rx_images/ \
--device /dev/bus/usb \
-p 5003:5003 \