diff --git a/__main__.py b/__main__.py index f4d793e..78a2c2f 100755 --- a/__main__.py +++ b/__main__.py @@ -28,8 +28,8 @@ if __name__ == "__main__": verbose = args.verbose - proj = ProjectorSerial() - extr = ExtronSerial() + proj = ProjectorSerial(verbose) + extr = ExtronSerial(verbose) if args.input: proj.power_on() diff --git a/extron.py b/extron.py index fef40dd..3d649ef 100644 --- a/extron.py +++ b/extron.py @@ -36,8 +36,8 @@ class ExtronSerial(SerialDevice): baudrate = 9600 super().__init__(serial_port, baudrate, verbose) - def send_command(self, command: str, verbose: bool = False) -> str: - response = super().send_command(command, verbose) + def send_command(self, command: str) -> str: + response = super().send_command(command) if response[0] == "E": print(response, self.ERRORS.get(response, "Unknown")) diff --git a/projector.py b/projector.py index 55b3dc5..b799f43 100644 --- a/projector.py +++ b/projector.py @@ -11,14 +11,12 @@ class ProjectorSerial(SerialDevice): super().__init__(serial_port, baudrate, verbose) - def send_command( - self, command: str, verbose: bool = False, device_id: str = "ZZ" - ) -> str: + def send_command(self, command: str, device_id: str = "ZZ") -> str: assert device_id in ["01", "02", "03", "04", "05", "06", "ZZ"] full_command = f"\x02AD{device_id};{command}\x03" - return super().send_command(full_command, verbose) + return super().send_command(full_command) def power_on(self) -> None: self.send_command("PON") diff --git a/serialdevice.py b/serialdevice.py index f34d64f..a48d9f7 100644 --- a/serialdevice.py +++ b/serialdevice.py @@ -10,11 +10,10 @@ class SerialDevice: self.baudrate = baudrate self.verbose = verbose - def send_command(self, command: str, verbose: bool = False) -> str: - verbose = verbose or self.verbose + def send_command(self, command: str) -> str: with Serial(self.serial_port, self.baudrate, timeout=1) as s: - if verbose: + if self.verbose: print("Send:", command) s.write(command.encode()) @@ -30,7 +29,7 @@ class SerialDevice: else: response = "" - if verbose: + if self.verbose: print("Resp:", response) if not response: print("No response")