Verbose
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user