Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
OCopping committed Mar 11, 2024
1 parent cc28527 commit 6b156ee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/fastcs/connections/modbus_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
AsyncModbusUdpClient,
ModbusBaseClient,
)

from pymodbus.exceptions import ModbusException
from pymodbus.framer import Framer
from pymodbus.pdu import ExceptionResponse, ModbusResponse
Expand Down Expand Up @@ -42,9 +41,11 @@ async def _read(self, address: int, count: int = 2) -> Optional[ModbusResponse]:
# address -= 1 # modbus spec starts from 0 not 1
try:

Check warning on line 42 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L42

Added line #L42 was not covered by tests
# address_hex = hex(address)
rr = await self._client.read_holding_registers(address, count=count, slave=self.slave) # type: ignore
rr = await self._client.read_holding_registers(

Check warning on line 44 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L44

Added line #L44 was not covered by tests
address, count=count, slave=self.slave
) # type: ignore

if rr.isError() or isinstance(rr, ExceptionResponse): # pragma no cover
if rr.isError() or isinstance(rr, ExceptionResponse): # pragma no cover
# Received Modbus library error or exception
# THIS EXCEPTION IS NOT A PYTHON EXCEPTION, but a valid modbus message
self.disconnect()
Expand Down Expand Up @@ -72,7 +73,7 @@ class ModbusSerialConnection(ModbusConnection):
def __init__(self, settings: ModbusConnectionSettings) -> None:
super().__init__(settings)

Check warning on line 74 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L74

Added line #L74 was not covered by tests

async def connect(self, framer: Framer=Framer.SOCKET):
async def connect(self, framer: Framer = Framer.SOCKET):
self._client = AsyncModbusSerialClient(

Check warning on line 77 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L77

Added line #L77 was not covered by tests
str(self.port),
framer=framer,
Expand All @@ -95,7 +96,7 @@ class ModbusTcpConnection(ModbusConnection):
def __init__(self, settings: ModbusConnectionSettings) -> None:
super().__init__(settings)

Check warning on line 97 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L97

Added line #L97 was not covered by tests

async def connect(self, framer: Framer=Framer.SOCKET):
async def connect(self, framer: Framer = Framer.SOCKET):
self._client = AsyncModbusTcpClient(

Check warning on line 100 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L100

Added line #L100 was not covered by tests
self.host,
self.port,
Expand All @@ -116,7 +117,7 @@ class ModbusUdpConnection(ModbusConnection):
def __init__(self, settings: ModbusConnectionSettings) -> None:
super().__init__(settings)

Check warning on line 118 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L118

Added line #L118 was not covered by tests

async def connect(self, framer: Framer=Framer.SOCKET):
async def connect(self, framer: Framer = Framer.SOCKET):
self._client = AsyncModbusUdpClient(

Check warning on line 121 in src/fastcs/connections/modbus_connection.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/connections/modbus_connection.py#L121

Added line #L121 was not covered by tests
self.host,
self.port,
Expand Down

0 comments on commit 6b156ee

Please sign in to comment.