Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions API_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ API changes 3.13.0
------------------
- removed RemoteDeviceContext, because it only is a partial forwarder
a proper forwarder should be made at frame level.
- datastore get/setValues only exist as async_get/set

API changes 3.12.0
------------------
Expand Down
Binary file modified doc/source/_static/examples.tgz
Binary file not shown.
Binary file modified doc/source/_static/examples.zip
Binary file not shown.
17 changes: 0 additions & 17 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ Source: :github:`examples/server_async.py`
:noindex:


Server callback
^^^^^^^^^^^^^^^
Source: :github:`examples/server_callback.py`

.. automodule:: examples.server_callback
:undoc-members:
:noindex:


Server tracer
^^^^^^^^^^^^^
Source: :github:`examples/server_hook.py`
Expand Down Expand Up @@ -176,11 +167,3 @@ Source: :github:`examples/contrib/solar.py`
:undoc-members:
:noindex:


Serial Forwarder
^^^^^^^^^^^^^^^^
Source: :github:`examples/contrib/serial_forwarder.py`

.. automodule:: examples.contrib.serial_forwarder
:undoc-members:
:noindex:
70 changes: 0 additions & 70 deletions examples/server_callback.py

This file was deleted.

2 changes: 1 addition & 1 deletion examples/server_updating.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def updating_task(context):
This task runs continuously beside the server
It will increment some values each two seconds.

It should be noted that getValues and setValues are not safe
It should be noted that async_getValues and async_setValues are not safe
against concurrent use.
"""
func_code = 3
Expand Down
37 changes: 6 additions & 31 deletions pymodbus/datastore/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
# pylint: disable=missing-type-doc

class ModbusBaseDeviceContext:
"""Interface for a modbus device data context.

Derived classes must implemented the following methods:
reset(self)
getValues/async_getValues(self, func_code, address, count=1)
setValues/async_setValues(self, func_code, address, values)
"""
"""Interface for a modbus device data context."""

_fx_mapper = {2: "d", 4: "i"}
_fx_mapper.update([(i, "h") for i in (3, 6, 16, 22, 23)])
Expand All @@ -35,25 +29,6 @@ def decode(self, fx):
async def async_getValues(self, func_code: int, address: int, count: int = 1) -> list[int] | list[bool] | ExcCodes:
"""Get `count` values from datastore.

:param func_code: The function we are working with
:param address: The starting address
:param count: The number of values to retrieve
:returns: The requested values from a:a+c
"""
return self.getValues(func_code, address, count)

async def async_setValues(self, func_code: int, address: int, values: list[int] | list[bool] ) -> None | ExcCodes:
"""Set the datastore with the supplied values.

:param func_code: The function we are working with
:param address: The starting address
:param values: The new values to be set
"""
return self.setValues(func_code, address, values)

def getValues(self, func_code: int, address: int, count: int = 1) -> list[int] | list[bool] | ExcCodes:
"""Get `count` values from datastore.

:param func_code: The function we are working with
:param address: The starting address
:param count: The number of values to retrieve
Expand All @@ -62,7 +37,7 @@ def getValues(self, func_code: int, address: int, count: int = 1) -> list[int] |
Log.error("getValues({},{},{}) not implemented!", func_code, address, count)
return ExcCodes.ILLEGAL_FUNCTION

def setValues(self, func_code: int, address: int, values: list[int] | list[bool]) -> None | ExcCodes:
async def async_setValues(self, func_code: int, address: int, values: list[int] | list[bool] ) -> None | ExcCodes:
"""Set the datastore with the supplied values.

:param func_code: The function we are working with
Expand Down Expand Up @@ -110,7 +85,7 @@ def reset(self):
for datastore in iter(self.store.values()):
datastore.reset()

def getValues(self, func_code, address, count=1) -> list[int] | list[bool] | ExcCodes:
async def async_getValues(self, func_code, address, count=1) -> list[int] | list[bool] | ExcCodes:
"""Get `count` values from datastore.

:param func_code: The function we are working with
Expand All @@ -120,9 +95,9 @@ def getValues(self, func_code, address, count=1) -> list[int] | list[bool] | Exc
"""
address += 1
Log.debug("getValues: fc-[{}] address-{}: count-{}", func_code, address, count)
return self.store[self.decode(func_code)].getValues(address, count)
return await self.store[self.decode(func_code)].async_getValues(address, count)

def setValues(self, func_code, address, values) -> None | ExcCodes:
async def async_setValues(self, func_code, address, values) -> None | ExcCodes:
"""Set the datastore with the supplied values.

:param func_code: The function we are working with
Expand All @@ -131,7 +106,7 @@ def setValues(self, func_code, address, values) -> None | ExcCodes:
"""
address += 1
Log.debug("setValues[{}] address-{}: count-{}", func_code, address, len(values))
return self.store[self.decode(func_code)].setValues(address, values)
return await self.store[self.decode(func_code)].async_setValues(address, values)


class ModbusServerContext:
Expand Down
121 changes: 0 additions & 121 deletions pymodbus/datastore/remote.py

This file was deleted.

4 changes: 2 additions & 2 deletions pymodbus/datastore/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def reset(self):
"""Reset the datastore to the initialized default value."""
self.values = [self.default_value] * len(self.values)

def getValues(self, address, count=1) -> list[int] | list[bool] | ExcCodes:
async def async_getValues(self, address, count=1) -> list[int] | list[bool] | ExcCodes:
"""Return the requested values of the datastore.

:param address: The starting address
Expand All @@ -58,7 +58,7 @@ def getValues(self, address, count=1) -> list[int] | list[bool] | ExcCodes:
return ExcCodes.ILLEGAL_ADDRESS
return self.values[start : start + count]

def setValues(self, address, values) -> None | ExcCodes:
async def async_setValues(self, address, values) -> None | ExcCodes:
"""Set the requested values of the datastore.

:param address: The starting address
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/datastore/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def validate(self, func_code, address, count=1):
fx_write = func_code in self._write_func_code
return self.loop_validate(real_address, real_address + count, fx_write)

def getValues(self, func_code, address, count=1) -> list[int] | list[bool] | ExcCodes:
async def async_getValues(self, func_code, address, count=1) -> list[int] | list[bool] | ExcCodes:
"""Return the requested values of the datastore.

:meta private:
Expand Down Expand Up @@ -624,7 +624,7 @@ def getValues(self, func_code, address, count=1) -> list[int] | list[bool] | Exc
bit_index = 0
return result

def setValues(self, func_code, address, values) -> None | ExcCodes:
async def async_setValues(self, func_code, address, values) -> None | ExcCodes:
"""Set the requested values of the datastore.

:meta private:
Expand Down
Loading