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
Copy file name to clipboardExpand all lines: changelog.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
<!-- ## [Unreleased] -->
16
16
17
17
## Released
18
+
## [2.1.0] - 2022-12-17
19
+
### Added
20
+
- Typing hints available for all functions of [umodbus](umodbus), see #27
21
+
- Docstrings available for all constants, functions and classes of [umodbus](umodbus/), see #27
22
+
- Test for reading more than 8 coils in a row to verify fix of #36
23
+
- Test for reading single negative holding register value
24
+
- Test for writing multiple coils to verify fix of #22
25
+
- Test for writing multiple registers to verify fix of #23
26
+
- Usage documentation for coil, discrete inputs, holding register and input register usage
27
+
- Modbus TCP IP and port binding can be checked with `is_bound` property in [tcp.py](umodbus/tcp.py)
28
+
29
+
### Changed
30
+
- Reordered modules of API documentation
31
+
-`data_as_registers` and `data_as_bits` of [common.py](umodbus/common.py) removed
32
+
- Send illegal function code `0x01` if a register other than coil or holding register is requested to be set
33
+
- Simplified `_process_write_access` logic of [tcp.py](umodbus/tcp.py)
34
+
35
+
### Fixed
36
+
- Typing hints of function input parameters and return values
37
+
- Response data of multiple changed registers (`write_multiple_registers`) is validated with respect to the provided `signed` flag in [serial.py](umodbus/serial.py) and [tcp.py](umodbus/tcp.py), see #23
38
+
- Enable reading more than 8 coils in a row, see #36
39
+
- Writing multiple coils in TCP, see #22
40
+
- Writing multiple registers in TCP, see #23
41
+
- Unit test `test_bytes_to_bool` uses MSB and LSB data correctly
42
+
18
43
## [2.0.0] - 2022-12-03
19
44
### Added
20
45
- Perform MicroPython based unittests on every `Test` workflow run
@@ -151,8 +176,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
151
176
- PEP8 style issues on all files of [`lib/uModbus`](lib/uModbus)
All described functions require a successful setup of a Host communicating
235
+
to/with a Client device which is providing the data and accepting the new data.
236
+
237
+
```python
238
+
from umodbus.tcp importTCPas ModbusTCPMaster
239
+
240
+
slave_tcp_port =502# port to listen to
241
+
slave_addr =10# bus address of client
242
+
slave_ip ='192.168.178.69'# IP address, to be adjusted
243
+
244
+
host = ModbusTCPMaster(
245
+
slave_ip=slave_ip,
246
+
slave_port=slave_tcp_port,
247
+
timeout=5) # optional, default 5
248
+
```
249
+
250
+
#### Coils
251
+
252
+
Coils represent binary states, which can be get as and set to either `0` (off)
253
+
or `1` (on).
254
+
255
+
##### Read
256
+
257
+
> The function code `0x01` is used to read from 1 to 2000 contiguous status of
258
+
coils in a remote device.
259
+
260
+
With the function [`read_coils`](umodbus.tcp.TCP.read_coils) a single coil
261
+
status can be read.
262
+
263
+
```python
264
+
coil_address =125
265
+
coil_qty =2
266
+
coil_status = host.read_coils(
267
+
slave_addr=slave_addr,
268
+
starting_addr=coil_address,
269
+
coil_qty=coil_qty)
270
+
print('Status of COIL {}: {}'.format(coil_address, coil_status))
271
+
# Status of COIL 125: [True, False]
272
+
```
273
+
274
+
> :warning: Please be aware of bug
275
+
[#35](https://github.com/brainelectronics/micropython-modbus/issues/35). It is
276
+
not possible to read a specific position within a configured list of multiple
277
+
coils on a MicroPython Modbus TCP client device. Reading coil 126 in the above
278
+
example will throw an error. This bug affects only devices using this package.
279
+
Other devices work as expected and can be addressed as specified.
280
+
281
+
##### Write
282
+
283
+
Coils can be set with `False` or `0` to the `OFF` state and with `True` or `1`
284
+
to the `ON` state.
285
+
286
+
###### Single
287
+
288
+
> The function code `0x05` is used to write a single output to either `ON` or
289
+
`OFF` in a remote device.
290
+
291
+
With the function [`write_single_coil`](umodbus.tcp.TCP.write_single_coil)
292
+
a single coil status can be set.
293
+
294
+
```python
295
+
coil_address =123
296
+
new_coil_val =0
297
+
operation_status = host.write_single_coil(
298
+
slave_addr=slave_addr,
299
+
output_address=coil_address,
300
+
output_value=new_coil_val)
301
+
print('Result of setting COIL {}: {}'.format(coil_address, operation_status))
302
+
# Result of setting COIL 123: True
303
+
```
304
+
305
+
> :warning: Please be aware of bug
306
+
[#15](https://github.com/brainelectronics/micropython-modbus/issues/15). It is
307
+
not possible to write to a specific position within a configured list of multiple coils on a MicroPython Modbus TCP client device. This bug affects only
308
+
devices using this package. Other devices work as expected and can be addressed
309
+
as specified.
310
+
311
+
###### Multiple
312
+
313
+
> The function code `0x0F` is used to force each coil in a sequence of coils to
314
+
either `ON` or `OFF` in a remote device.
315
+
316
+
With the function [`write_multiple_coils`](umodbus.tcp.TCP.write_multiple_coils)
print('Result of setting COIL {}: {}'.format(coil_address, operation_status))
327
+
# Result of setting COIL 126: True
328
+
```
329
+
330
+
> :warning: Please be aware of bug
331
+
[#35](https://github.com/brainelectronics/micropython-modbus/issues/35). It is
332
+
not possible to write to a specific position within a configured list of multiple coils on a MicroPython Modbus TCP client device. Setting coil 127, which is `1` in the above example will throw an error. This bug affects only
333
+
devices using this package. Other devices work as expected and can be addressed
334
+
as specified.
335
+
336
+
#### Discrete inputs
337
+
338
+
Discrete inputs represent binary states, which can be get as either `0` (off)
339
+
or `1` (on). Unlike [coils](#coils), these cannot be set.
340
+
341
+
##### Read
342
+
343
+
> The function code `0x02` is used to read from 1 to 2000 contiguous status of
344
+
discrete inputs in a remote device.
345
+
346
+
With the function [`read_discrete_inputs`](umodbus.tcp.TCP.read_discrete_inputs)
347
+
discrete inputs can be read.
348
+
349
+
```python
350
+
ist_address =68
351
+
input_qty =2
352
+
input_status = host.read_discrete_inputs(
353
+
slave_addr=slave_addr,
354
+
starting_addr=ist_address,
355
+
input_qty=input_qty)
356
+
print('Status of IST {}: {}'.format(ist_address, input_status))
357
+
# Status of IST 68: [True, False]
358
+
```
359
+
360
+
#### Holding registers
361
+
362
+
Holding registers can be get as and set to any value between `0` and `65535`.
363
+
If supported by the client device, data can be marked as signed values to
364
+
represent `-32768` through `32767`.
365
+
366
+
##### Read
367
+
368
+
> The function code `0x03` is used to read the contents of a contiguous block
369
+
of holding registers in a remote device.
370
+
371
+
With the function
372
+
[`read_holding_registers`](umodbus.tcp.TCP.read_holding_registers) a single
373
+
holding register can be read.
374
+
375
+
```python
376
+
hreg_address =94
377
+
register_qty =3
378
+
register_value = host.read_holding_registers(
379
+
slave_addr=slave_addr,
380
+
starting_addr=hreg_address,
381
+
register_qty=register_qty,
382
+
signed=False)
383
+
print('Status of HREG {}: {}'.format(hreg_address, register_value))
384
+
# Status of HREG 94: [29, 38, 0]
385
+
```
386
+
387
+
> :warning: Please be aware of bug
388
+
[#35](https://github.com/brainelectronics/micropython-modbus/issues/35). It is
389
+
not possible to read a specific position within a configured list of multiple
390
+
holding registers on a MicroPython Modbus TCP client device. Reading holding
391
+
register 95, holding the value `38` in the above example will throw an error.
392
+
This bug affects only devices using this package. Other devices work as
393
+
expected and can be addressed as specified.
394
+
395
+
##### Write
396
+
397
+
Holding registers can be set to `0` through `65535` or `-32768` through `32767`
398
+
in case signed values are used.
399
+
400
+
###### Single
401
+
402
+
> The function code `0x06` is used to write a single holding register in a
403
+
remote device.
404
+
405
+
With the function
406
+
[`write_single_register`](umodbus.tcp.TCP.write_single_register) a single
407
+
holding register can be set.
408
+
409
+
```python
410
+
hreg_address =93
411
+
new_hreg_val =44
412
+
operation_status = host.write_single_register(
413
+
slave_addr=slave_addr,
414
+
register_address=hreg_address,
415
+
register_value=new_hreg_val,
416
+
signed=False)
417
+
print('Result of setting HREG {}: {}'.format(hreg_address, operation_status))
418
+
# Result of setting HREG 93: True
419
+
```
420
+
421
+
###### Multiple
422
+
423
+
> The function code `0x10` is used to write a block of contiguous registers
0 commit comments