diff --git a/src/fprime_gds/executables/cli.py b/src/fprime_gds/executables/cli.py index 20c7e528..40f76b5d 100644 --- a/src/fprime_gds/executables/cli.py +++ b/src/fprime_gds/executables/cli.py @@ -31,21 +31,8 @@ from fprime_gds.executables.utils import find_app, find_dict, get_artifacts_root from fprime_gds.plugin.definitions import PluginType from fprime_gds.plugin.system import Plugins +from fprime_gds.common.zmq_transport import ZmqClient -# Optional import: ZeroMQ. Requires package: pyzmq -try: - import zmq - - from fprime_gds.common.zmq_transport import ZmqClient -except ImportError: - zmq = None - ZmqClient = None - -# Optional import: Serial Adapter. Requires package: SerialAdapter -try: - from fprime_gds.common.communication.adapters.uart import SerialAdapter -except ImportError: - SerialAdapter = None GUIS = ["none", "html"] @@ -197,7 +184,6 @@ def parse_args( sys.exit(-1) except Exception as exc: print(f"[ERROR] {exc}", file=sys.stderr) - raise sys.exit(-1) return args_ns, parser @@ -578,40 +564,37 @@ class MiddleWareParser(ParserBase): def get_arguments(self) -> Dict[Tuple[str, ...], Dict[str, Any]]: """Return arguments necessary to run a and connect to the GDS middleware""" - # May use ZMQ transportation layer if zmq package is available - zmq_arguments = {} - if zmq is not None and ZmqClient is not None: - zmq_arguments = { - ("--zmq",): { - "dest": "zmq", - "action": "store_true", - "help": "Switch to using the ZMQ transportation layer", - "default": False, - }, - ("--zmq-transport",): { - "dest": "zmq_transport", - "nargs": 2, - "help": "Pair of URls used with --zmq to setup ZeroMQ transportation [default: %(default)s]", - "default": [ - "ipc:///tmp/fprime-server-in", - "ipc:///tmp/fprime-server-out", - ], - "metavar": ("serverInUrl", "serverOutUrl"), - }, - } + zmq_arguments = { + ("--no-zmq",): { + "dest": "zmq", + "action": "store_false", + "help": "Disable ZMQ transportation layer, falling back to TCP socket server.", + "default": True, + }, + ("--zmq-transport",): { + "dest": "zmq_transport", + "nargs": 2, + "help": "Pair of URls used with --zmq to setup ZeroMQ transportation [default: %(default)s]", + "default": [ + "ipc:///tmp/fprime-server-in", + "ipc:///tmp/fprime-server-out", + ], + "metavar": ("serverInUrl", "serverOutUrl"), + }, + } tts_arguments = { ("--tts-port",): { "dest": "tts_port", "action": "store", "type": int, - "help": "Set the threaded TCP socket server port [default: %(default)s]", + "help": "Set the threaded TCP socket server port when ZMQ is not used [default: %(default)s]", "default": 50050, }, ("--tts-addr",): { "dest": "tts_addr", "action": "store", "type": str, - "help": "Set the threaded TCP socket server address [default: %(default)s]", + "help": "Set the threaded TCP socket server address when ZMQ is not used [default: %(default)s]", "default": "0.0.0.0", }, } @@ -626,7 +609,6 @@ def handle_arguments(self, args, **kwargs): :return: args namespace """ is_client = kwargs.get("client", False) - args.zmq = getattr(args, "zmq", False) tts_connection_address = ( args.tts_addr.replace("0.0.0.0", "127.0.0.1") if is_client diff --git a/src/fprime_gds/executables/comm.py b/src/fprime_gds/executables/comm.py index 94cf6e1d..04b49f9f 100644 --- a/src/fprime_gds/executables/comm.py +++ b/src/fprime_gds/executables/comm.py @@ -19,20 +19,16 @@ import logging import signal import sys - from pathlib import Path # Required adapters built on standard tools -try: - from fprime_gds.common.zmq_transport import ZmqGround -except ImportError: - ZmqGround = None import fprime_gds.common.communication.adapters.base import fprime_gds.common.communication.adapters.ip import fprime_gds.common.communication.ground import fprime_gds.common.logger import fprime_gds.executables.cli from fprime_gds.common.communication.updown import Downlinker, Uplinker +from fprime_gds.common.zmq_transport import ZmqGround # Uses non-standard PIP package pyserial, so test the waters before getting a hard-import crash try: @@ -68,11 +64,8 @@ def main(): sys.exit(-1) # Create the handling components for either side of this script, adapter for hardware, and ground for the GDS side - if args.zmq and ZmqGround is None: - print("[ERROR] ZeroMQ is not available. Install pyzmq.", file=sys.stderr) - sys.exit(-1) - elif args.zmq: - ground = fprime_gds.common.zmq_transport.ZmqGround(args.zmq_transport) + if args.zmq: + ground = ZmqGround(args.zmq_transport) else: ground = fprime_gds.common.communication.ground.TCPGround( args.tts_addr, args.tts_port diff --git a/test/fprime_gds/test_plugins.py b/test/fprime_gds/test_plugins.py index 8221d73b..7ba14354 100644 --- a/test/fprime_gds/test_plugins.py +++ b/test/fprime_gds/test_plugins.py @@ -217,7 +217,7 @@ def start_up(request): extra_plugins, flags = request.param command_arguments = ["fprime-gds", "-n", "--dictionary", str( parent_path / "sample" / "dictionary.xml"), - "--zmq", "--zmq-transport", "ipc:///tmp/fprime-test-in", "ipc:///tmp/fprime-test-out", + "--zmq-transport", "ipc:///tmp/fprime-test-in", "ipc:///tmp/fprime-test-out", "-g", "none"] + flags # Update the environment to side-load python