Reenable verbose
This commit is contained in:
@@ -31,10 +31,10 @@ class ExtronSerial(SerialDevice):
|
|||||||
# w == escape
|
# w == escape
|
||||||
# | == carriage return
|
# | == carriage return
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, verbose: bool = False) -> None:
|
||||||
serial_port = "/dev/serial/by-id/usb-Extron_Product-if00"
|
serial_port = "/dev/serial/by-id/usb-Extron_Product-if00"
|
||||||
baudrate = 9600
|
baudrate = 9600
|
||||||
super().__init__(serial_port, baudrate)
|
super().__init__(serial_port, baudrate, verbose)
|
||||||
|
|
||||||
def send_command(self, command: str, verbose: bool = False) -> str:
|
def send_command(self, command: str, verbose: bool = False) -> str:
|
||||||
response = super().send_command(command, verbose)
|
response = super().send_command(command, verbose)
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ ETX = chr(0x03)
|
|||||||
|
|
||||||
|
|
||||||
class ProjectorSerial(SerialDevice):
|
class ProjectorSerial(SerialDevice):
|
||||||
def __init__(self) -> None:
|
def __init__(self, verbose: bool = False) -> None:
|
||||||
serial_port = "/dev/serial0"
|
serial_port = "/dev/serial0"
|
||||||
baudrate = 9600
|
baudrate = 9600
|
||||||
|
|
||||||
super().__init__(serial_port, baudrate)
|
super().__init__(serial_port, baudrate, verbose)
|
||||||
|
|
||||||
def send_command(
|
def send_command(
|
||||||
self, command: str, verbose: bool = False, device_id: str = "ZZ"
|
self, command: str, verbose: bool = False, device_id: str = "ZZ"
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ from serial import Serial
|
|||||||
|
|
||||||
|
|
||||||
class SerialDevice:
|
class SerialDevice:
|
||||||
def __init__(self, serial_port: str, baudrate: int = 9600) -> None:
|
def __init__(
|
||||||
|
self, serial_port: str, baudrate: int = 9600, verbose: bool = False
|
||||||
|
) -> None:
|
||||||
self.serial_port: str = serial_port
|
self.serial_port: str = serial_port
|
||||||
self.baudrate = baudrate
|
self.baudrate = baudrate
|
||||||
|
self.verbose = verbose
|
||||||
|
|
||||||
def send_command(self, command: str, verbose: bool = False) -> str:
|
def send_command(self, command: str, verbose: bool = False) -> str:
|
||||||
|
verbose = verbose or self.verbose
|
||||||
|
|
||||||
with Serial(self.serial_port, self.baudrate, timeout=1) as s:
|
with Serial(self.serial_port, self.baudrate, timeout=1) as s:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Send:", command)
|
print("Send:", command)
|
||||||
|
|||||||
Reference in New Issue
Block a user