-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Demon000/master
Allow passing host and port as command-line arguments
- Loading branch information
Showing
3 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (C) 2023, Tomi Valkeinen <[email protected]> | ||
|
||
import argparse | ||
import struct | ||
import sys | ||
import traceback | ||
|
@@ -13,7 +14,6 @@ | |
from PyQt6.QtCore import Qt | ||
import PyQt6.QtNetwork | ||
|
||
PORT = 43242 | ||
receivers = [] | ||
|
||
# ctx-idx, width, height, strides[4], format[16], num-planes, plane[4] | ||
|
@@ -195,15 +195,21 @@ def readkey(): | |
qApp.quit() | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Camera RX server') | ||
parser.add_argument('-H', '--host', default='0.0.0.0') | ||
parser.add_argument('-P', '--port', default=43242, type=int) | ||
args = parser.parse_args() | ||
|
||
qApp = QtWidgets.QApplication(sys.argv) | ||
qApp.setQuitOnLastWindowClosed(False) | ||
|
||
keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read) | ||
keynotif.activated.connect(readkey) | ||
|
||
tcpServer = PyQt6.QtNetwork.QTcpServer(qApp) | ||
tcpServer.listen(PyQt6.QtNetwork.QHostAddress('0.0.0.0'), PORT) | ||
tcpServer.listen(PyQt6.QtNetwork.QHostAddress(args.host), args.port) | ||
tcpServer.newConnection.connect(lambda: new_connection(tcpServer)) | ||
print(f'Network receive on {args.host}:{args.port}') | ||
|
||
return qApp.exec() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters