From 6642f8534d0118d60d16257e1a4898ffdebb28ef Mon Sep 17 00:00:00 2001 From: Axel Fischer Date: Wed, 24 Apr 2024 12:40:10 +0200 Subject: [PATCH] PREVAC TMC13 -> master is only assigned and released once even if multiple drivers connect to the same physical unit --- src/Logger-PREVAC_TMC13/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Logger-PREVAC_TMC13/main.py b/src/Logger-PREVAC_TMC13/main.py index 1b488f4c..f9ea7ad7 100644 --- a/src/Logger-PREVAC_TMC13/main.py +++ b/src/Logger-PREVAC_TMC13/main.py @@ -131,6 +131,9 @@ def set_GUIparameter(self) -> dict: # noqa: N802 def get_GUIparameter(self, parameter: dict) -> None: # noqa: N802 """Get parameters from the GUI and set them as attributes.""" + + self.port_string = parameter["Port"] + # Channel number must be of \x01 format channel = parameter["Channel"] self.channel = int(channel).to_bytes(1, byteorder="big").decode("latin1") @@ -170,11 +173,15 @@ def connect(self) -> None: ) self.register_host() - self.assign_master() + self.unique_identifier = "PREVAC_TMC13 - " + self.port_string + if self.unique_identifier not in self.device_communication: + self.assign_master() def disconnect(self) -> None: """End the remote control mode on the device.""" - self.release_master() + if self.unique_identifier in self.device_communication: + self.release_master() + del self.device_communication[self.unique_identifier] def initialize(self) -> None: """Get frequency range."""