diff --git a/mavsdk/system.py b/mavsdk/system.py index fb0fb101..f167bd85 100644 --- a/mavsdk/system.py +++ b/mavsdk/system.py @@ -39,17 +39,6 @@ from . import bin - -class _LoggingThread(threading.Thread): - def __init__(self, pipe, log_fn): - super().__init__() - self.pipe = pipe - self.log_fn = log_fn - - def run(self): - for line in self.pipe: - self.log_fn(line.decode("utf-8").replace("\n", "")) - class System: """ Instantiate a System object, that will serve as a proxy to @@ -85,7 +74,7 @@ def __init__(self, mavsdk_server_address=None, port=50051, sysid=245, compid=190 def __del__(self): self._stop_mavsdk_server() - async def connect(self, system_address=None): + async def connect(self, system_address=None, verbose=True): """ Connect the System object to a remote system. @@ -111,7 +100,7 @@ async def connect(self, system_address=None): if self._mavsdk_server_address is None: self._mavsdk_server_address = 'localhost' - self._server_process = self._start_mavsdk_server(system_address,self._port, self._sysid, self._compid) + self._server_process = self._start_mavsdk_server(system_address,self._port, self._sysid, self._compid, verbose) await self._init_plugins(self._mavsdk_server_address, self._port) @@ -352,7 +341,7 @@ def tune(self) -> tune.Tune: return self._plugins["tune"] @staticmethod - def _start_mavsdk_server(system_address, port, sysid, compid): + def _start_mavsdk_server(system_address, port, sysid, compid, verbose=True): """ Starts the gRPC server in a subprocess, listening on localhost:port port parameter can be specified now to allow multiple mavsdk servers to be spawned via code @@ -382,12 +371,8 @@ def _start_mavsdk_server(system_address, port, sysid, compid): bin_path_and_args.append(system_address) p = subprocess.Popen(bin_path_and_args, shell=False, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - - logger = logging.getLogger(__name__) - log_thread = _LoggingThread(p.stdout, logger.debug) - log_thread.start() + stdout=subprocess.DEVNULL if not verbose else None, + stderr=subprocess.DEVNULL if not verbose else None) except FileNotFoundError: print(""" This installation does not provide an embedded 'mavsdk_server' binary.