@@ -55,9 +55,9 @@ Pymodbus offers clients with transport different protocols and different framers
55
55
- ASCII
56
56
- RTU
57
57
- RTU_OVER_TCP
58
- - Socket
58
+ - SOCKET
59
59
- TLS
60
- * - Serial (RS-485)
60
+ * - SERIAL (RS-485)
61
61
- Yes
62
62
- Yes
63
63
- No
@@ -118,19 +118,32 @@ that a device have received the packet.
118
118
Client usage
119
119
------------
120
120
Using pymodbus client to set/get information from a device (server)
121
- is done in a few simple steps, like the following synchronous example::
121
+ is done in a few simple steps.
122
+
123
+ Synchronous example
124
+ ^^^^^^^^^^^^^^^^^^^
125
+
126
+ ::
122
127
123
128
from pymodbus.client import ModbusTcpClient
124
129
125
130
client = ModbusTcpClient('MyDevice.lan') # Create client object
126
- client.connect() # connect to device, reconnect automatically
131
+ client.connect() # connect to device
127
132
client.write_coil(1, True, slave=1) # set information in device
128
133
result = client.read_coils(2, 3, slave=1) # get information from device
129
134
print(result.bits[0]) # use information
130
135
client.close() # Disconnect device
131
136
137
+ The line :mod: `client.connect() ` connects to the device (or comm port). If this cannot connect successfully within
138
+ the timeout it throws an exception. After this initial connection, further
139
+ calls to the same client (here, :mod: `client.write_coil(...) ` and
140
+ :mod: `client.read_coils(...) ` ) will check whether the client is still
141
+ connected, and automatically reconnect if not.
132
142
133
- and a asynchronous example::
143
+ Asynchronous example
144
+ ^^^^^^^^^^^^^^^^^^^^
145
+
146
+ ::
134
147
135
148
from pymodbus.client import AsyncModbusTcpClient
136
149
@@ -141,7 +154,7 @@ and a asynchronous example::
141
154
print(result.bits[0]) # use information
142
155
client.close() # Disconnect device
143
156
144
- The line :mod: `client = AsyncModbusTcpClient('MyDevice.lan') ` only creates the object it does not activate
157
+ The line :mod: `client = AsyncModbusTcpClient('MyDevice.lan') ` only creates the object; it does not activate
145
158
anything.
146
159
147
160
The line :mod: `await client.connect() ` connects to the device (or comm port), if this cannot connect successfully within
@@ -153,6 +166,9 @@ The line :mod:`result = await client.read_coils(2, 3, slave=1)` is an example of
153
166
154
167
The last line :mod: `client.close() ` closes the connection and render the object inactive.
155
168
169
+ Development notes
170
+ ^^^^^^^^^^^^^^^^^
171
+
156
172
Large parts of the implementation are shared between the different classes,
157
173
to ensure high stability and efficient maintenance.
158
174
@@ -232,6 +248,20 @@ There are a client class for each type of communication and for asynchronous/syn
232
248
- :mod: `AsyncModbusUdpClient `
233
249
- :mod: `ModbusUdpClient `
234
250
251
+ Client common
252
+ ^^^^^^^^^^^^^
253
+ Some methods are common to all client:
254
+
255
+ .. autoclass :: pymodbus.client.base.ModbusBaseClient
256
+ :members:
257
+ :member-order: bysource
258
+ :show-inheritance:
259
+
260
+ .. autoclass :: pymodbus.client.base.ModbusBaseSyncClient
261
+ :members:
262
+ :member-order: bysource
263
+ :show-inheritance:
264
+
235
265
Client serial
236
266
^^^^^^^^^^^^^
237
267
.. autoclass :: pymodbus.client.AsyncModbusSerialClient
0 commit comments