jmri_ncemonitor.transport.port

BytePort ABC — read-only-by-convention byte stream.

We define write() for symmetry with other drivers, but the monitor never calls it. Subclasses that connect to real RS-485 adapters may implement write as a raise; the loopback impl supports writes so tests can feed traffic to the monitor.

 1"""``BytePort`` ABC — read-only-by-convention byte stream.
 2
 3We define :meth:`write` for symmetry with other drivers, but the monitor
 4never calls it. Subclasses that connect to real RS-485 adapters may
 5implement ``write`` as a raise; the loopback impl supports writes so
 6tests can feed traffic *to* the monitor.
 7"""
 8from __future__ import annotations
 9
10from abc import ABC, abstractmethod
11
12
13class BytePort(ABC):
14    @abstractmethod
15    async def write(self, data: bytes) -> None: ...
16
17    @abstractmethod
18    async def read_byte(self) -> int: ...
19
20    @abstractmethod
21    async def aclose(self) -> None: ...
22
23    @property
24    @abstractmethod
25    def is_open(self) -> bool: ...
class BytePort(abc.ABC):
14class BytePort(ABC):
15    @abstractmethod
16    async def write(self, data: bytes) -> None: ...
17
18    @abstractmethod
19    async def read_byte(self) -> int: ...
20
21    @abstractmethod
22    async def aclose(self) -> None: ...
23
24    @property
25    @abstractmethod
26    def is_open(self) -> bool: ...

Helper class that provides a standard way to create an ABC using inheritance.

@abstractmethod
async def write(self, data: bytes) -> None:
15    @abstractmethod
16    async def write(self, data: bytes) -> None: ...
@abstractmethod
async def read_byte(self) -> int:
18    @abstractmethod
19    async def read_byte(self) -> int: ...
@abstractmethod
async def aclose(self) -> None:
21    @abstractmethod
22    async def aclose(self) -> None: ...
is_open: bool
24    @property
25    @abstractmethod
26    def is_open(self) -> bool: ...