Skip to content

Commit 55edf15

Browse files
committed
cam-rx: allow configuring host and port
1 parent 64fc07b commit 55edf15

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utils/cam-rx.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: BSD-3-Clause
44
# Copyright (C) 2023, Tomi Valkeinen <[email protected]>
55

6+
import argparse
67
import struct
78
import sys
89
import traceback
@@ -13,7 +14,6 @@
1314
from PyQt6.QtCore import Qt
1415
import PyQt6.QtNetwork
1516

16-
PORT = 43242
1717
receivers = []
1818

1919
# ctx-idx, width, height, strides[4], format[16], num-planes, plane[4]
@@ -195,15 +195,21 @@ def readkey():
195195
qApp.quit()
196196

197197
def main():
198+
parser = argparse.ArgumentParser(description='Camera RX server')
199+
parser.add_argument('-H', '--host', default='0.0.0.0')
200+
parser.add_argument('-P', '--port', default=43242, type=int)
201+
args = parser.parse_args()
202+
198203
qApp = QtWidgets.QApplication(sys.argv)
199204
qApp.setQuitOnLastWindowClosed(False)
200205

201206
keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
202207
keynotif.activated.connect(readkey)
203208

204209
tcpServer = PyQt6.QtNetwork.QTcpServer(qApp)
205-
tcpServer.listen(PyQt6.QtNetwork.QHostAddress('0.0.0.0'), PORT)
210+
tcpServer.listen(PyQt6.QtNetwork.QHostAddress(args.host), args.port)
206211
tcpServer.newConnection.connect(lambda: new_connection(tcpServer))
212+
print(f'Network receive on {args.host}:{args.port}')
207213

208214
return qApp.exec()
209215

0 commit comments

Comments
 (0)