| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- from dataclasses import dataclass
- from enum import Enum
- from typing import Annotated
- from beartype import beartype
- from beartype.vale import Is
- class NBusBaudrate(Enum):
- """
- Enum class for serial baudrate speed.
- """
- SPEED_9600 = 9600
- SPEED_19200 = 19200
- SPEED_38400 = 38400
- SPEED_57600 = 7600
- SPEED_115200 = 115200
- SPEED_230400 = 230400
- SPEED_460800 = 460800
- SPEED_576000 = 576000
- SPEED_921600 = 921600
- class NBusParity(Enum):
- """
- Enum class for serial parity.
- """
- NONE = "N"
- ODD = "O"
- EVEN = "E"
- @beartype
- @dataclass(frozen=True)
- class NBusSerialConfig:
- """
- Configuration of serial port.
- :ivar port_name: The serial port identifier.
- :ivar baud: The baud rate for the serial communication.
- :ivar parity: The parity bit setting for the serial communication.
- :ivar timeout: The timeout value for the serial communication.
- :ivar request_attempts: The number of attempts for a request.
- :ivar enable_log: Flag to enable or disable logging.
- """
- port_name: str
- baud: NBusBaudrate
- parity: NBusParity
- timeout: Annotated[float, Is[lambda value: value > 0]]
- request_attempts: Annotated[int, Is[lambda value: value > 0]]
- enable_log: bool
|