|
16 | 16 | sys.path.append(f"{os.path.dirname(__file__)}/src")
|
17 | 17 | from pyairios.client import AsyncAiriosModbusRtuClient
|
18 | 18 |
|
19 |
| -from pyairios.brdg_02r13 import BRDG02R13, DEFAULT_SLAVE_ID as BRDG02R13_DEFAULT_SLAVE_ID |
| 19 | +from pyairios.brdg_02r13 import ( |
| 20 | + BRDG02R13, |
| 21 | + DEFAULT_SLAVE_ID as BRDG02R13_DEFAULT_SLAVE_ID, |
| 22 | + SerialConfig, |
| 23 | +) |
20 | 24 | from pyairios.constants import (
|
| 25 | + Baudrate, |
| 26 | + Parity, |
21 | 27 | ProductId,
|
22 | 28 | ResetMode,
|
| 29 | + StopBits, |
23 | 30 | VMDBypassMode,
|
24 | 31 | VMDRequestedVentilationSpeed,
|
25 | 32 | VMDVentilationSpeed,
|
@@ -340,6 +347,17 @@ async def do_serial_config(self) -> None:
|
340 | 347 | res = await self.bridge.serial_config()
|
341 | 348 | print(f"Serial Config: {res}")
|
342 | 349 |
|
| 350 | + async def do_set_serial_config(self, baudrate: int, parity: str, stop_bits: int) -> None: |
| 351 | + """Set the serial configuration. |
| 352 | +
|
| 353 | + The bridge must be reset to make new settings effective.""" |
| 354 | + b = Baudrate.parse(baudrate) |
| 355 | + p = Parity.parse(parity) |
| 356 | + s = StopBits.parse(stop_bits) |
| 357 | + config = SerialConfig(b, p, s) |
| 358 | + if await self.bridge.set_serial_config(config): |
| 359 | + print("Reset the bridge with `reset` command to make new settings effective.") |
| 360 | + |
343 | 361 | async def do_uptime(self) -> None:
|
344 | 362 | """Print the device uptime."""
|
345 | 363 | res = await self.bridge.power_on_time()
|
|
0 commit comments