Skip to content

Commit 435f52d

Browse files
committed
Add isError() method to Modbus exceptions (refer #298), updated changelogs, bumped version to 1.5.1
1 parent 08fa109 commit 435f52d

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Version 1.5.1
2+
------------------------------------------------------------
3+
* Fix device information selectors
4+
* Fixed behaviour of the MEI device information command as a server when an invalid object_id is provided by an external client.
5+
* Add support for repeated MEI device information Object IDs (client/server)
6+
* Added support for encoding device information when it requires more than one PDU to pack.
7+
* Added REPR statements for all syncchronous clients
8+
* Added `isError` method to exceptions, Any response received can be tested for success before proceeding.
9+
10+
```
11+
res = client.read_holding_registers(...)
12+
if not res.isError():
13+
# proceed
14+
else:
15+
# handle error or raise
16+
```
17+
* Add examples for MEI read device information request
18+
119
Version 1.5.0
220
------------------------------------------------------------
321
* Improve transaction speeds for sync clients (RTU/ASCII), now retry on empty happens only when retry_on_empty kwarg is passed to client during intialization

pymodbus/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def __init__(self, string):
1818
def __str__(self):
1919
return 'Modbus Error: %s' % self.string
2020

21+
def isError(self):
22+
"""Error"""
23+
return True
24+
2125

2226
class ModbusIOException(ModbusException):
2327
''' Error resulting from data i/o '''

pymodbus/pdu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def __init__(self, **kwargs):
129129
ModbusPDU.__init__(self, **kwargs)
130130

131131
def isError(self):
132+
"""Checks if the error is a success or failure"""
132133
return self.function_code > 0x80
133134

134135

pymodbus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __str__(self):
4141
return '[%s, version %s]' % (self.package, self.short())
4242

4343

44-
version = Version('pymodbus', 1, 5, 0)
44+
version = Version('pymodbus', 1, 5, 1)
4545

4646

4747
version.__name__ = 'pymodbus' # fix epydoc error

0 commit comments

Comments
 (0)