You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
await client.connect() # connect to device, reconnect automatically
152
+
await client.write_coil(1, True, device_id=1) # set information in device
153
+
result = await client.read_coils(2, 3, device_id=1) # get information from device
154
+
print(result.bits[0]) # use information
155
+
client.close() # Disconnect device
156
156
157
157
The line :mod:`client = AsyncModbusTcpClient('MyDevice.lan')` only creates the object; it does not activate
158
158
anything.
159
159
160
160
The line :mod:`await client.connect()` connects to the device (or comm port), if this cannot connect successfully within
161
161
the timeout it throws an exception. If connected successfully reconnecting later is handled automatically
162
162
163
-
The line :mod:`await client.write_coil(1, True, slave=1)` is an example of a write request, set address 1 to True on device 1 (slave).
163
+
The line :mod:`await client.write_coil(1, True, device_id=1)` is an example of a write request, set address 1 to True on device 1.
164
164
165
-
The line :mod:`result = await client.read_coils(2, 3, slave=1)` is an example of a read request, get the value of address 2, 3 and 4 (count = 3) from device 1 (slave).
165
+
The line :mod:`result = await client.read_coils(2, 3, device_id=1)` is an example of a read request, get the value of address 2, 3 and 4 (count = 3) from device 1.
166
166
167
167
The last line :mod:`client.close()` closes the connection and render the object inactive.
168
168
@@ -194,13 +194,13 @@ Client device addressing
194
194
------------------------
195
195
196
196
With **TCP**, **TLS** and **UDP**, the tcp/ip address of the physical device is defined when creating the object.
197
-
Logical devices represented by the device is addressed with the :mod:`slave=` parameter.
197
+
Logical devices represented by the device is addressed with the :mod:`device_id=` parameter.
198
198
199
199
With **Serial**, the comm port is defined when creating the object.
200
-
The physical devices are addressed with the :mod:`slave=` parameter.
200
+
The physical devices are addressed with the :mod:`device_id=` parameter.
201
201
202
-
:mod:`slave=0` is defined as broadcast in the modbus standard, but pymodbus treats it as a normal device.
203
-
please note :mod:`slave=0` can only be used to address devices that truly have id=0 ! Using :mod:`slave=0` to
202
+
:mod:`device_id=0` is defined as broadcast in the modbus standard, but pymodbus treats it as a normal device.
203
+
please note :mod:`device_id=0` can only be used to address devices that truly have id=0 ! Using :mod:`device_id=0` to
204
204
address a single device with id not 0 is against the protocol.
205
205
206
206
If an application is expecting multiple responses to a broadcast request, it must call :mod:`client.execute` and deal with the responses.
@@ -217,7 +217,7 @@ All simple request calls (mixin) return a unified result independent whether it
217
217
The application should evaluate the result generically::
218
218
219
219
try:
220
-
rr = await client.read_coils(1, 1, slave=1)
220
+
rr = await client.read_coils(1, 1, device_id=1)
221
221
except ModbusException as exc:
222
222
_logger.error(f"ERROR: exception in pymodbus {exc}")
0 commit comments