Skip to content

Commit 8ca23bf

Browse files
paulocarvalhoctwaigarius
authored andcommitted
Add configurable DLT port to py_dlt_receive
`py_dlt_receive` always connect to the hardcoded `DLT_DAEMON_TCP_PORT` (3490) because the CLI never exposed a port option and passed nothing to `DLTBroker`. This adds a `--port` argument so a custom DLT daemon port can be used.
1 parent b5afe1a commit 8ca23bf

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

dlt/py_dlt_receive.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import time
77

8-
from dlt.dlt import DLT_UDP_MULTICAST_FD_BUFFER_SIZE, DLT_UDP_MULTICAST_BUFFER_SIZE
8+
from dlt.dlt import DLT_DAEMON_TCP_PORT, DLT_UDP_MULTICAST_FD_BUFFER_SIZE, DLT_UDP_MULTICAST_BUFFER_SIZE
99
from dlt.dlt_broker import DLTBroker
1010

1111
logging.basicConfig(format="%(asctime)s %(name)s %(levelname)-8s %(message)s")
@@ -18,6 +18,12 @@ def parse_args():
1818
logger.info("Parsing arguments")
1919
parser = argparse.ArgumentParser(description="Receive DLT messages")
2020
parser.add_argument("--host", required=True, help="hostname or ip address to connect to")
21+
parser.add_argument(
22+
"--port",
23+
default=DLT_DAEMON_TCP_PORT,
24+
type=int,
25+
help=f"Port of the DLT Daemon to connect to. default: {DLT_DAEMON_TCP_PORT}",
26+
)
2127
parser.add_argument("--file", required=True, help="The file into which the messages will be written")
2228
parser.add_argument(
2329
"--udp-fd-buffer-size",
@@ -41,6 +47,7 @@ def dlt_receive(options):
4147
logger.info("Creating DLTBroker instance")
4248
broker = DLTBroker(
4349
ip_address=options.host,
50+
port=options.port,
4451
filename=options.file,
4552
udp_fd_buffer_size_bytes=options.udp_buffer_size,
4653
udp_buffer_size_bytes=options.udp_fd_buffer_size,

0 commit comments

Comments
 (0)