Add config option for image port, to enable separation of multiple wenet decoder instances

rfm98w_packettx
Mark Jessop 2024-10-04 13:22:04 +09:30
rodzic dac359f76e
commit a626e5d260
9 zmienionych plików z 52 dodań i 16 usunięć

Wyświetl plik

@ -19,7 +19,7 @@ from base64 import b64encode
# Check if we are running in Python 2 or 3
PY3 = sys.version_info[0] == 3
WENET_VERSION = "1.1.0"
WENET_VERSION = "1.2.0"
WENET_IMAGE_UDP_PORT = 7890
WENET_TELEMETRY_UDP_PORT = 55672

Wyświetl plik

@ -167,11 +167,11 @@ class FSKDemodStats(object):
def send_modem_stats(stats):
def send_modem_stats(stats, udp_port=WENET_IMAGE_UDP_PORT):
""" Send a JSON-encoded dictionary to the wenet frontend """
try:
gui_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
gui_socket.sendto(json.dumps(stats).encode('ascii'), ("127.0.0.1", WENET_IMAGE_UDP_PORT))
gui_socket.sendto(json.dumps(stats).encode('ascii'), ("127.0.0.1", udp_port))
gui_socket.close()
except Exception as e:
@ -186,12 +186,15 @@ if __name__ == "__main__":
parser.add_argument("--freq", default=441200000, type=float, help="IQ Centre Frequency (Hz)")
parser.add_argument("--samplerate", default=921416, type=float, help="Sample rate (Hz)")
parser.add_argument("--real", default=False, action="store_true", help="Real Samples (not IQ)")
parser.add_argument("--image_port", type=int, default=None, help="UDP port used for communication between Wenet decoder processes. Default: 7890")
args = parser.parse_args()
_averaging_time = 1.0/args.rate
stats_parser = FSKDemodStats(averaging_time=_averaging_time, peak_hold=True, freq=args.freq, sample_rate=args.samplerate, real=args.real)
# Overwrite the image UDP port if it has been provided
if args.image_port:
WENET_IMAGE_UDP_PORT = args.image_port
_last_update_time = time.time()
@ -220,7 +223,7 @@ if __name__ == "__main__":
'time': datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%SZ")
}
send_modem_stats(_stats)
send_modem_stats(_stats, udp_port=WENET_IMAGE_UDP_PORT)
_last_update_time = time.time()

Wyświetl plik

@ -131,6 +131,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="Verbose output")
parser.add_argument("--image_port", type=int, default=None, help="UDP port used for communication between Wenet decoder processes. Default: 7890")
args = parser.parse_args()
if args.verbose:
@ -140,6 +141,10 @@ if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=log_level)
# Overwrite the image UDP port if it has been provided
if args.image_port:
WENET_IMAGE_UDP_PORT = args.image_port
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName('SSDV Viewer')

Wyświetl plik

@ -30,10 +30,19 @@ parser.add_argument("--partialupdate", default=0, help="Push partial updates eve
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="Verbose output")
parser.add_argument("--headless", action='store_true', default=False, help="Headless mode - broadcasts additional data via UDP.")
parser.add_argument("--rximages", default="./rx_images/", help="Location to save RX images and telemetry to.")
parser.add_argument("--image_port", type=int, default=None, help="UDP port used for communication between Wenet decoder processes. Default: 7890")
parser.add_argument("--telemetry_port", type=int, default=None, help="UDP port used to emit telemetry to other applications. Default: 55672")
args = parser.parse_args()
RX_IMAGES_DIR = args.rximages
# Overwrite the image and telemetry UDP ports if they have been provided
if args.image_port:
WENET_IMAGE_UDP_PORT = args.image_port
if args.telemetry_port:
WENET_TELEMETRY_UDP_PORT = args.telemetry_port
# Set up log output.
if args.verbose:
log_level = logging.DEBUG
@ -50,6 +59,8 @@ LOG_FILENAME = os.path.join(args.rximages,datetime.datetime.utcnow().strftime("%
# GUI updates are only sent locally.
def trigger_gui_update(filename, text = "None", metadata = None):
global WENET_IMAGE_UDP_PORT
message = {'filename': filename,
'text': text,
'metadata': metadata}
@ -62,6 +73,7 @@ def trigger_gui_update(filename, text = "None", metadata = None):
# Telemetry packets are send via UDP broadcast in case there is other software on the local
# network that wants them.
def broadcast_telemetry_packet(data, headless=False):
global WENET_IMAGE_UDP_PORT, WENET_TELEMETRY_UDP_PORT
telemetry_socket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
# Set up the telemetry socket so it can be re-used.
telemetry_socket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)

Wyświetl plik

@ -113,7 +113,7 @@ class SSDVUploader(object):
def ssdv_upload_single(self, packet):
_packet_dict = self.ssdv_encode_packet(packet,callsign)
_packet_dict = self.ssdv_encode_packet(packet)
_attempts = 1
while _attempts <= self.upload_retries:

Wyświetl plik

@ -24,6 +24,7 @@ fi
: "${BAUD_RATE:=115177}"
: "${OVERSAMPLING:=8}"
: "${UDP_PORT:=0}"
: "${IMAGE_PORT:=7890}"
# Start up the SSDV Uploader script and push it into the background.
python3 ssdvuploader.py "$MYCALL" &
@ -33,7 +34,7 @@ SSDV_UPLOAD_PID=$!
if [ "$UDP_PORT" = "0" ]; then
python3 wenetserver.py "$MYCALL" &
else
python3 wenetserver.py "$MYCALL" -u "$UDP_PORT" &
python3 wenetserver.py "$MYCALL" -u "$UDP_PORT" --image_port "$IMAGE_PORT" &
fi
WEB_VIEWER_PID=$!
@ -57,9 +58,9 @@ fi
# Start up the receive chain.
echo "Using Complex Samples."
rtl_sdr -d "$DEVICE" -s "$SDR_RATE" -f "$RX_SSB_FREQ" -g "$GAIN" - | \
./fsk_demod --cu8 -s --stats=100 2 "$SDR_RATE" "$BAUD_RATE" - - 2> >(python3 fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE) | \
./fsk_demod --cu8 -s --stats=100 2 "$SDR_RATE" "$BAUD_RATE" - - 2> >(python3 fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --image_port "$IMAGE_PORT") | \
./drs232_ldpc - - -vv 2> /dev/null | \
python3 rx_ssdv.py --partialupdate 16 --headless
python3 rx_ssdv.py --partialupdate 16 --headless --image_port "$IMAGE_PORT"
# Kill off the SSDV Uploader and the GUIs
kill $SSDV_UPLOAD_PID

Wyświetl plik

@ -334,6 +334,7 @@ if __name__ == "__main__":
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", default=False, action='store_true', help="Disable SondeHub-Amateur position upload.")
parser.add_argument("--image_port", type=int, default=None, help="UDP port used for communication between Wenet decoder processes. Default: 7890")
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()
@ -354,6 +355,10 @@ if __name__ == "__main__":
if args.udp_port:
udp_emit_port = args.udp_port
# Overwrite the image UDP port if it has been provided
if args.image_port:
WENET_IMAGE_UDP_PORT = args.image_port
logging.getLogger("werkzeug").setLevel(logging.ERROR)
logging.getLogger("socketio").setLevel(logging.ERROR)
logging.getLogger("engineio").setLevel(logging.ERROR)

Wyświetl plik

@ -49,6 +49,11 @@ OVERSAMPLING=8
UDP_PORT=0
# UDP Port used for Wenet inter-process communication.
# If you are intenting on running more than one Wenet instance on the same computer
# (e.g. multiple docker containers), use a different port for each instance.
IMAGE_PORT=7890
# Stop and remove any existing wenet instances
echo "Stopping/Removing any existing Wenet instances..."
docker stop wenet || true && docker rm wenet || true
@ -65,6 +70,7 @@ docker run -d \
-e OVERSAMPLING=$OVERSAMPLING \
-e DEVICE=$DEVICE \
-e UDP_PORT=$UDP_PORT \
-e IMAGE_PORT=$IMAGE_PORT \
-v ~/wenet/rx_images/:/opt/wenet/rx_images/ \
--device /dev/bus/usb \
-p 5003:5003 \

Wyświetl plik

@ -76,6 +76,10 @@ OVERSAMPLING=8 # FSK Demod Oversampling rate. Not used in GQRX mode.
#BAUD_RATE=4800
#OVERSAMPLING=200
# UDP Port used for Wenet inter-process communication.
# If you are intenting on running more than one Wenet instance on the same computer
# (e.g. multiple docker containers), use a different port for each instance.
IMAGE_PORT=7890
#
# Main Script Start... Don't edit anything below this unless you know what you're doing!
@ -94,7 +98,7 @@ python ssdvuploader.py $MYCALL &
SSDV_UPLOAD_PID=$!
# Start the Web Interface Server
python wenetserver.py $MYCALL &
python wenetserver.py --image_port $IMAGE_PORT $MYCALL &
WEB_VIEWER_PID=$!
@ -126,9 +130,9 @@ if [ "$RX_FLOW" = "IQ" ]; then
echo "Using Complex Samples."
rtl_sdr -s $SDR_RATE -f $RX_SSB_FREQ -g $GAIN - | \
./fsk_demod --cu8 -s --stats=100 2 $SDR_RATE $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE) | \
./fsk_demod --cu8 -s --stats=100 2 $SDR_RATE $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --image_port $IMAGE_PORT ) | \
./drs232_ldpc - - -vv 2> /dev/null | \
python rx_ssdv.py --partialupdate 16 --headless
python rx_ssdv.py --partialupdate 16 --headless --image_port $IMAGE_PORT
elif [ "$RX_FLOW" = "GQRX" ]; then
# GQRX Mode - take 48kHz real samples from GQRX via UDP.
# TODO: Check the following netcat command works OK under all OSes...
@ -136,9 +140,9 @@ elif [ "$RX_FLOW" = "GQRX" ]; then
# Might need to try: nc -l -u -p 7355 localhost
echo "Receiving samples from GQRX on UDP:localhost:7355"
nc -l -u localhost 7355 | \
./fsk_demod -s --stats=100 -b 1 -u 23500 2 48000 $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --real) | \
./fsk_demod -s --stats=100 -b 1 -u 23500 2 48000 $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --real --image_port $IMAGE_PORT ) | \
./drs232_ldpc - - -vv 2> /dev/null | \
python rx_ssdv.py --partialupdate 4 --headless
python rx_ssdv.py --partialupdate 4 --headless --image_port $IMAGE_PORT
else
# If using a RTLSDR that has a DC spike (i.e. either has a FitiPower FC0012 or Elonics E4000 Tuner),
# we receive below the centre frequency, and perform USB demodulation.
@ -147,9 +151,9 @@ else
rtl_sdr -s $SDR_RATE -f $RX_SSB_FREQ -g $GAIN - | csdr convert_u8_f | \
csdr bandpass_fir_fft_cc 0.05 0.45 0.05 | csdr realpart_cf | \
csdr gain_ff 0.5 | csdr convert_f_s16 | \
./fsk_demod -s --stats=100 2 $SDR_RATE $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --real) | \
./fsk_demod -s --stats=100 2 $SDR_RATE $BAUD_RATE - - 2> >(python fskstatsudp.py --rate 1 --freq $RX_SSB_FREQ --samplerate $SDR_RATE --real --image_port $IMAGE_PORT ) | \
./drs232_ldpc - - -vv 2> /dev/null | \
python rx_ssdv.py --partialupdate 16 --headless
python rx_ssdv.py --partialupdate 16 --headless --image_port $IMAGE_PORT
fi