Skip to content

Commit 8512581

Browse files
committed
Split server into each transport.
1 parent 9304a92 commit 8512581

22 files changed

+164
-1300
lines changed

doc/source/library/pymodbus.client.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
================
24
pymodbus\.client
35
================

doc/source/library/pymodbus.server.rst

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
================
2+
pymodbus\.server
3+
================
4+
5+
Pymodbus offers servers with transport protocols for
6+
7+
- *Serial* (RS-485) typically using a dongle
8+
- *TCP*
9+
- *TLS*
10+
- *UDP*
11+
- possibility to add a custom transport protocol
12+
13+
communication in 2 versions:
14+
15+
- :mod:`synchronous server`,
16+
- :mod:`asynchronous server` using asyncio.
17+
18+
*Remark* All servers are implemented with asyncio, and the
19+
synchronous servers are just an interface layer allowing synchronous
20+
applications to use the server as if it was synchronous.
21+
22+
123
pymodbus\.server package
224
========================
325

@@ -9,18 +31,10 @@ pymodbus\.server package
931
Submodules
1032
----------
1133

12-
pymodbus\.server\.asynchronous module
13-
-------------------------------------
34+
pymodbus\.server module
35+
-----------------------
1436

1537
.. automodule:: pymodbus.server.async_io
1638
:members:
1739
:undoc-members:
1840
:show-inheritance:
19-
20-
pymodbus\.server\.sync module
21-
-----------------------------
22-
23-
.. automodule:: pymodbus.server.sync
24-
:members:
25-
:undoc-members:
26-
:show-inheritance:

examples/common/callback_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ModbusSparseDataBlock,
1717
)
1818
from pymodbus.device import ModbusDeviceIdentification
19-
from pymodbus.server.async_io import StartTcpServer
19+
from pymodbus.server import StartTcpServer
2020

2121
# --------------------------------------------------------------------------- #
2222
# import the modbus libraries we need

examples/common/custom_datablock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ModbusSparseDataBlock,
1414
)
1515
from pymodbus.device import ModbusDeviceIdentification
16-
from pymodbus.server.async_io import StartTcpServer
16+
from pymodbus.server import StartTcpServer
1717

1818
# --------------------------------------------------------------------------- #
1919
# import the modbus libraries we need

examples/common/custom_synchronous_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def decode(self, data):
6767
ModbusSlaveContext,
6868
)
6969
from pymodbus.device import ModbusDeviceIdentification
70-
from pymodbus.server.sync import StartTcpServer
70+
from pymodbus.server import StartTcpServer
7171
from pymodbus.version import version
7272

7373

examples/common/dbstore_update_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pymodbus.datastore import ModbusSequentialDataBlock, ModbusServerContext
2121
from pymodbus.datastore.database import SqlSlaveContext
2222
from pymodbus.device import ModbusDeviceIdentification
23-
from pymodbus.server.async_io import StartTcpServer
23+
from pymodbus.server import StartAsyncTcpServer
2424

2525
# --------------------------------------------------------------------------- #
2626
# import the modbus libraries we need
@@ -68,7 +68,7 @@ def updating_writer(parm1):
6868
log.debug(txt)
6969

7070

71-
def run_dbstore_update_server():
71+
async def run_dbstore_update_server():
7272
"""Run dbstore update server."""
7373
# ----------------------------------------------------------------------- #
7474
# initialize your data store
@@ -100,8 +100,8 @@ def run_dbstore_update_server():
100100
loop = asyncio.get_event_loop()
101101
loop.start(time, now=False) # initially delay by time
102102
loop.stop()
103-
StartTcpServer(context, identity=identity, address=("", 5020))
103+
await StartAsyncTcpServer(context, identity=identity, address=("", 5020))
104104

105105

106106
if __name__ == "__main__":
107-
run_dbstore_update_server()
107+
asyncio.run(run_dbstore_update_server())

examples/common/payload_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)
1515
from pymodbus.device import ModbusDeviceIdentification
1616
from pymodbus.payload import BinaryPayloadBuilder
17-
from pymodbus.server.async_io import StartTcpServer
17+
from pymodbus.server import StartAsyncTcpServer
1818

1919
# --------------------------------------------------------------------------- #
2020
# import the various server implementations
@@ -73,7 +73,7 @@ async def run_payload_server():
7373
"MajorMinorRevision": version.short(),
7474
}
7575
)
76-
server = await StartTcpServer(
76+
server = await StartAsyncTcpServer(
7777
context,
7878
identity=identity,
7979
address=("0.0.0.0", 5020),

examples/common/updating_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ModbusSlaveContext,
1919
)
2020
from pymodbus.device import ModbusDeviceIdentification
21-
from pymodbus.server.async_io import StartTcpServer
21+
from pymodbus.server import StartAsyncTcpServer
2222
from pymodbus.version import version
2323

2424

@@ -85,7 +85,7 @@ async def run_updating_server():
8585
# run the server you want
8686
# ----------------------------------------------------------------------- #
8787
log.debug("Start server")
88-
await StartTcpServer(
88+
await StartAsyncTcpServer(
8989
context, identity=identity, address=("localhost", 5020), defer_start=False
9090
)
9191
log.debug("Done")

examples/contrib/deviceinfo_showcase_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from pymodbus import __version__ as pymodbus_version
1414
from pymodbus.datastore import ModbusServerContext, ModbusSlaveContext
1515

16-
# from pymodbus.server.sync import StartUdpServer
17-
# from pymodbus.server.sync import StartSerialServer
16+
# from pymodbus.server import StartUdpServer
17+
# from pymodbus.server import StartSerialServer
1818
# from pymodbus.transaction import ModbusRtuFramer, ModbusBinaryFramer
1919
from pymodbus.device import ModbusDeviceIdentification
20-
from pymodbus.server.sync import StartTcpServer
20+
from pymodbus.server import StartTcpServer
2121

2222
# --------------------------------------------------------------------------- #
2323
# import the various server implementations

examples/contrib/modbus_mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
3939
from modbus_mapper import csv_mapping_parser
4040
from modbus_mapper import modbus_context_decoder
41-
from pymodbus.client.ssync import StartTcpServer
41+
from pymodbus.server import StartTcpServer
4242
from pymodbus.datastore.context import ModbusServerContext
4343
4444
template = ["address", "value", "function", "name", "description"]

0 commit comments

Comments
 (0)