Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
262 commits
Select commit Hold shift + click to select a range
b09de19
adding another quick example
bashwork Apr 11, 2011
56b981c
cutting 200 pep8 errors
bashwork Apr 12, 2011
a2a7b8a
working on py3 merge
bashwork May 11, 2011
b7a3b4e
updating to python3
bashwork May 11, 2011
2b687c9
reverting back changes, remember Switch flag next time
bashwork May 11, 2011
d81d68a
adding some magic methods, just cause
bashwork May 11, 2011
92c2474
adding documentation pdf
bashwork May 19, 2011
bb1ab65
Fixes issue 49
bashwork May 24, 2011
5e4f7a8
Adds True and False constants for older python versions.
bashwork Jun 15, 2011
e276a93
adding tests for a few fixes
bashwork Jun 15, 2011
d1b4de2
Fixes issue 51
bashwork Aug 30, 2011
ecdfc19
fixing tests broken by interface change
bashwork Aug 30, 2011
40fb366
Updates issue 52
bashwork Aug 30, 2011
7c9c7b1
Fixes issue 53
bashwork Aug 31, 2011
ec8d571
Fix to add Python < 2.5 compatibility
bashwork Aug 31, 2011
305769f
adding a mostly complete diagnostic register implementation
bashwork Aug 31, 2011
297b16c
Adding more documentation and helpful factory methods.
bashwork Aug 31, 2011
f45eb91
adding modbus plus registers
bashwork Aug 31, 2011
a4d6811
adding endian ability to payload builder
bashwork Sep 6, 2011
d5a4402
Finishing the remaining modbus protocol
bashwork Sep 6, 2011
f0f594b
finished file read/write record requests
bashwork Sep 7, 2011
fcd572e
documentation, more tests, fixing extra commands
bashwork Sep 7, 2011
87eb6a4
adding more tests
bashwork Sep 7, 2011
2885f4f
Fixing the client/server async/sync implementations
bashwork Sep 9, 2011
9a82d03
adding test stubs to get full coverage count
bashwork Sep 9, 2011
5df1779
working on jamod, need to set up more complete project
bashwork Sep 9, 2011
ce574cb
adding GetDeviceInformationRequest
bashwork Sep 16, 2011
b97932a
adding read device information to decoder factory
bashwork Sep 16, 2011
ead17cf
fixing some example errors
bashwork Oct 18, 2011
0773775
working on the serial implementations
bashwork Oct 19, 2011
6e480d1
fixing the synchronous server implementation
bashwork Oct 19, 2011
d49a5d3
updating functional tests and documentation for sync-serial
bashwork Oct 19, 2011
8899ac9
updating tac files
bashwork Oct 19, 2011
6c5ebdd
Updating the documentation for the serial client/servers
bashwork Nov 20, 2011
0c28dfa
adding readme to root
bashwork Dec 5, 2011
a92c341
Fixes issue 56
bashwork Jan 17, 2012
59f8cb0
Fixes issue 1
bashwork Jan 17, 2012
3e48cf3
adding a requirements file for virtualenv folk
bashwork Jan 17, 2012
dd9fb0d
adding more cohesive code to the payload utilities
bashwork Feb 26, 2012
92a52f5
forgot to add the new example to the doc index
bashwork Feb 26, 2012
f91cef1
Fixing the rtu size calculation isse #55 on google code
bashwork Feb 26, 2012
b83e12c
using the endian flag in register factory
bashwork Feb 26, 2012
cb25def
fixing bad documentation
bashwork Mar 13, 2012
707c6df
fixing issue 58 on google code
bashwork Mar 22, 2012
6544edc
Fix binary framer and add start and end tokens
Mar 29, 2012
5189c2f
Merge pull request #5 from deuxpi/binary-framer-fix
bashwork Mar 30, 2012
9270f2b
Adding checking in the client for an unconnected socket.
bashwork May 2, 2012
bc4898a
Fixing issue 60 on google code (including ez_setup)
bashwork May 2, 2012
58f3de8
fixing github issue #7
bashwork May 21, 2012
fbf8717
adding tests and two utilities
bashwork May 22, 2012
4b2afcc
adding message parser utility
bashwork May 22, 2012
c71fe2d
Fixing extended message decoding
bashwork May 23, 2012
cbf6e84
ModbusSparseDataBlock handled dictionaries incorrectly (they have an …
gjbroom Jun 7, 2012
178ca95
Merge pull request #8 from gjbroom/patch-1
bashwork Jun 7, 2012
d1de763
Updating the Readme.rst to explain how to install in zero dependency …
bashwork Jun 18, 2012
1f380a4
Fixing issue #10
bashwork Jun 18, 2012
6dc259c
updating the client documentation
bashwork Jun 18, 2012
3b191bd
updating the server context documentation
bashwork Jun 18, 2012
b444383
fixes #9 on github
bashwork Jun 18, 2012
5c47b8e
fixing the factory decoding and adding examples
bashwork Jun 18, 2012
46c58e0
pushing to version 1.0
bashwork Jun 18, 2012
2c84fe4
Fixing a bug in the asynchronous client that slipped through.
bashwork Jun 19, 2012
a57c87d
complete tests for the sync client
bashwork Jun 19, 2012
4f42698
cleaning up some pep8 errors
bashwork Jun 19, 2012
1409221
finished unit tests for async client
bashwork Jun 20, 2012
c7f1121
adding another test to the test-install script
bashwork Jun 20, 2012
c6bf024
finished covering sync client
bashwork Jun 28, 2012
dd4913a
updating documentation
bashwork Jun 29, 2012
f43765d
adding another example, adding debug checks
bashwork Jul 2, 2012
e6e20a4
Fixing the serial implementation of everything
bashwork Jul 2, 2012
c584ebf
fixing incorrect rtu lenght calculation
bashwork Jul 12, 2012
8f2c834
Add optional server_address to Sync and Async TCP/UDP Server API
pjkundert Jul 13, 2012
c232a95
Improve erver_address defaults to passing None
pjkundert Jul 13, 2012
eb2f67d
adding a few messages
bashwork Jul 14, 2012
726a423
Adding a message encoding generator for testing.
bashwork Jul 16, 2012
2f97b9b
adding documentation for message formats
bashwork Jul 16, 2012
e1e81b0
Merge pull request #12 from pjkundert/feature-server-address
bashwork Jul 24, 2012
26c7b04
updating documentation and being pedantic
bashwork Jul 24, 2012
0bf3974
Allowing overloading of message encoding
bashwork Sep 27, 2012
d4791f9
Cleaning up the build tools
bashwork Oct 2, 2012
8285cfb
adding support for pydev
bashwork Oct 4, 2012
dbc902d
fixing broken nosetest (/dev/pts) and pydev issues
bashwork Oct 4, 2012
5ba1915
adding bcd payload builder
bashwork Oct 10, 2012
07a499d
reworking contrib packages
bashwork Oct 11, 2012
7ab52cc
adding bcd payload contrib
bashwork Oct 11, 2012
49d0e5e
moving complex examples to contrib
bashwork Oct 11, 2012
a97322b
syncing version on pypi
bashwork Oct 11, 2012
bfcac1f
adding server rest api
bashwork Oct 12, 2012
ed99242
moving web -> bottle
bashwork Oct 12, 2012
fca1500
fixing documentation
bashwork Oct 12, 2012
f697aed
adding gui base
bashwork Oct 15, 2012
dbd4a45
adding initial manager page
bashwork Oct 17, 2012
89098d0
adding data view
bashwork Oct 17, 2012
7d418f2
fixing error in example
bashwork Nov 21, 2012
b304d74
adding the ability to override sync client framer
bashwork Dec 16, 2012
c335d45
updating the performance test
bashwork Dec 16, 2012
545c50d
fixing documentation
bashwork Dec 17, 2012
814ef1c
fixing memory leak in sync client
bashwork Dec 17, 2012
1e5f89d
adding modicon encoder/decoder
bashwork Jan 9, 2013
85945b7
Fix bogus calculation in ModbusSocketFramer.checkFrame
pitrou Jan 28, 2013
ad8a826
Adding sunspec client example
bashwork Feb 3, 2013
04ee590
adding method to retrieve all the device blocks
bashwork Feb 6, 2013
e6e2485
adding the initial mapper interface
bashwork Feb 7, 2013
727c0f5
adding ideas in progress
bashwork Feb 8, 2013
fd99353
adding a modbus datastore saver
bashwork Feb 13, 2013
bce03ed
making lrc/crc read stdin
bashwork Feb 25, 2013
7f6be9b
adding the callback server example
bashwork Mar 17, 2013
68a9346
adding a periodic updating example
bashwork Mar 17, 2013
ecd072a
fixing documentation
bashwork Mar 17, 2013
a968fdb
adding fix for stuck RTU streams
bashwork Mar 20, 2013
874fba3
fixing documentation error
bashwork Mar 20, 2013
0dff42f
Adding an example for changing framers
bashwork Mar 29, 2013
0b291f1
Merge pull request #16 from pitrou/framing-bug
bashwork Apr 2, 2013
61b2b80
Reworking the transaction managers to be explicit
bashwork Apr 2, 2013
69d8225
Bumping the version and adding a changelog
bashwork Apr 2, 2013
1884452
Fixing a logic error in client code
Apr 3, 2013
14a037d
Fixing 2to3 common warnings
May 13, 2013
f7575ea
Fixed example typo in readme
bashwork Jun 5, 2013
d98b372
Adding slave context delete ability
Jun 5, 2013
3e0e5e5
Fixing google code issue 69
bashwork Jun 19, 2013
7f9e3c9
Fixed docstring in synchronous serial client connect() method
idahogray Jun 20, 2013
ea19769
Merge pull request #24 from idahogray/master
bashwork Jul 8, 2013
1d4aa0a
Fix for issue #21
bashwork Jul 15, 2013
a8abfa2
Allowing options to be passed through
bashwork Jul 15, 2013
4703dfa
Adding source_address to TCP client inputs
bashwork Jul 28, 2013
8614024
Typo
jonmills Oct 11, 2013
d7ba4a3
Typo
jonmills Oct 11, 2013
6006481
Typo
jonmills Oct 11, 2013
b5b257a
Typo
jonmills Oct 11, 2013
2cc252f
Merge pull request #35 from jonmills/master
bashwork Oct 22, 2013
77ea6a9
Adding some new examples
Oct 23, 2013
be82996
Adding a concurrent client example
Oct 28, 2013
637a8f6
Allow specification of client connection handler in Modbus...Server
pjkundert Feb 20, 2014
42ee863
Merge pull request #44 from pjkundert/develop
bashwork Jul 18, 2014
6c6213d
Fixes #46
Jul 18, 2014
f6c7c95
Fixes #48
Jul 18, 2014
8c432d6
Adds the option to drop into zero mode for slaves
Jul 23, 2014
0693806
Fixes #42
Jul 23, 2014
ca02f9c
Bumping the version to 1.3.0
Jul 23, 2014
3ca9a38
add missing self operator
schubduese42 Aug 8, 2014
0ca8b5e
typo: fix spelling of Parameter
karlp Sep 30, 2014
87e35e0
async: missing slaves: add missing imports
karlp Sep 30, 2014
fd850ad
Fix zero_mode argument for ModbusSlaveContext
canpolat Oct 24, 2014
41131ee
Fix typo in constants
canpolat Oct 24, 2014
e0723d1
Adding an example and adding tcp timeout
Jan 5, 2015
6535037
fixes #70
Jan 5, 2015
2389d5e
Endianness now used in packing bytes
patrickfuller Jan 7, 2015
333c224
Merge pull request #67 from canpolat/zero_mode
bashwork Feb 18, 2015
14f68ac
Merge pull request #71 from patrickfuller/master
bashwork Feb 18, 2015
4038e22
Merge pull request #65 from remakeelectric/trivial-typo
bashwork Feb 18, 2015
93730d3
Merge pull request #53 from schubduese42/master
bashwork Feb 18, 2015
8c3a16c
Merge pull request #66 from remakeelectric/async-missing-import
bashwork Feb 18, 2015
e12323c
Adding a libmodbus wrapper
Mar 31, 2015
deadfdb
closes #73
Apr 2, 2015
0a78044
Execute methods of Requests accept context
Apr 2, 2015
bfda8f9
Add Modbus RTU syncronous server example
Apr 2, 2015
56628b1
Signal handlers to stop in shutdown().
estan May 3, 2015
e202e3a
WriteMultipleRegistersRequest: Handle values=None case
sjlongland Jun 3, 2015
ea98abe
Fix payload tests.
sjlongland Jun 4, 2015
6247f5f
sync.ModbusUdpClient: Correct reference to settimeout.
sjlongland Jun 4, 2015
e7cbe24
test-client-sync: Fix UDP connection test.
sjlongland Jun 4, 2015
82052fc
Lazily initialize InstallManagementConsole
joshkel Sep 1, 2015
7cf058a
Fixes the UDP client socket timeout bug
Sep 26, 2015
942776f
Merge pull request #99 from joshkel/master
bashwork Sep 26, 2015
acfe818
Merge pull request #88 from vrtsystems/fix-udp-sync-client
bashwork Sep 26, 2015
8ca7cef
Merge pull request #79 from BartDeWaal/master
bashwork Sep 26, 2015
5801fa0
Merge pull request #81 from estan/master
bashwork Sep 26, 2015
6949fbf
Implement mask_write_register method in client mixin
inguin Oct 5, 2015
6903ef9
Merge pull request #100 from inguin/master
bashwork Oct 13, 2015
1f529d0
Workaround for bug 101 https://github.com/bashwork/pymodbus/issues/101
dhoomakethu Oct 16, 2015
11f7392
Workaround for bug 101 https://github.com/bashwork/pymodbus/issues/101
dhoomakethu Oct 16, 2015
03277f9
Riptide 1.3.0 pymodbus internal pre-release (riptide1) with dhoomaket…
Oct 20, 2015
5900b66
Riptide 1.3.0 pymodbus internal pre-release (riptide1) with dhoomaket…
Oct 20, 2015
e3205b7
Use a PEP 404 compliant version. Start at rc93101 to usurp any other…
Oct 20, 2015
d42fc9d
Use a PEP 404 compliant version. Start at rc93101 to usurp any other…
Oct 20, 2015
4161e35
Document Riptide specific instructions.
Oct 20, 2015
e38c0d9
Merge branch 'master' into riptide (Workaround for bug 101 bashwork#101)
Oct 21, 2015
7511f4b
Merge branch 'master' into riptide (Workaround for bug 101 bashwork#101)
Oct 21, 2015
334cc20
Include Workaround for bug 101 bashwork#101
Oct 21, 2015
b1f2341
Include Workaround for bug 101 bashwork#101
Oct 21, 2015
f4627e0
Merge branch 'fix-101' into patch-fix-101
dhoomakethu Oct 21, 2015
0bc53d5
Better tag names.
Oct 21, 2015
94d6861
pymodbus fix for modes RTU error cases.
dhoomakethu Nov 16, 2015
42e6a3e
Merge pull request #1 from dhoomakethu/patch-fix-101-for-serial-modbus
dhoomakethu Nov 17, 2015
1e14754
version bumped to c93103
dhoomakethu Nov 20, 2015
b21aa1b
version bumped to c93103
dhoomakethu Nov 20, 2015
054da1d
Merged in patch-fix-101-for-serial-modbus-version-bumped (pull reques…
Nov 20, 2015
a6b41fc
fixed issue with pymodbus timing over serial
dhoomakethu Dec 23, 2015
c040d58
fixed issue with pymodbus timing over serial
dhoomakethu Dec 23, 2015
15711d5
Add RIPTIDE.md to .gitignore
dhoomakethu Dec 23, 2015
24ebb9d
Merge branch 'master' into timing-enhancements
dhoomakethu Dec 23, 2015
a2e18e5
Merge pull request #2 from dhoomakethu/timing-enhancements
dhoomakethu Dec 23, 2015
2ce2535
Merged in timing-enhancements (pull request #3)
dhoomakethu Jan 29, 2016
136c1b6
Merge branch 'master' of https://github.com/bashwork/pymodbus into ri…
dhoomakethu Nov 3, 2016
637e831
bump version to rc93105
dhoomakethu Nov 3, 2016
b593b79
1. fix bug with calculating expected pdu size for messages other than…
dhoomakethu May 5, 2017
6e4bb2e
sync bashwork/pymodbus master
dhoomakethu May 5, 2017
09be206
fix error with pdu size for messages other than read/write coil/regis…
dhoomakethu May 5, 2017
b88996b
fix merge conflicts
dhoomakethu May 5, 2017
b81124b
fix merge conflicts
dhoomakethu May 5, 2017
44e776e
fix version file
dhoomakethu May 5, 2017
37c2701
fix unit test failures
dhoomakethu May 5, 2017
7f11535
cleanup
dhoomakethu May 5, 2017
c92026b
#121 changelog updated
dhoomakethu May 12, 2017
eeb7014
1. preparing for release#162
dhoomakethu May 16, 2017
d728cc5
Merge branch 'master' into dev
dhoomakethu May 16, 2017
7ca9066
Misc update Add __maintainer__ field in setup.py
dhoomakethu May 16, 2017
d677fe5
1. #162, creating universal distribution for py2 and py3
dhoomakethu May 16, 2017
3fa5d00
fix test failures
dhoomakethu May 17, 2017
4697015
fix ReadDeviceInformationRequest encoding probelm
dhoomakethu May 17, 2017
0f8f1be
#166 fix failing tests on python 3.5
dhoomakethu May 20, 2017
08eacf9
Merge branch 'master' into dev
dhoomakethu May 20, 2017
057a371
mis - Updated documentation
dhoomakethu May 20, 2017
4e4f039
#167 updated documentation for CI
dhoomakethu May 20, 2017
b16cf55
#167 disable pep8/flake checks for the time being
dhoomakethu May 20, 2017
4db7e6b
#167, fix install dependencies osx, remove pypy from supported python…
dhoomakethu May 20, 2017
b0d863b
#167, fix install dependencies osx, remove pypy from supported python…
dhoomakethu May 20, 2017
a03bce5
#167 , fix minior error in travis.yml
dhoomakethu May 20, 2017
c0da663
Bump version to 1.3.0rc2
dhoomakethu May 20, 2017
b208242
Merge branch 'master' into dev
dhoomakethu May 20, 2017
f7c604b
Merge master
dhoomakethu May 21, 2017
ed0d54d
Fix #170 and other misc updates
dhoomakethu May 25, 2017
a53ea21
Updated Documents
dhoomakethu May 26, 2017
9773abf
Add coverage.rc to show missing lines with coverage >4.0
dhoomakethu May 26, 2017
fe4bafa
new documentation
dhoomakethu May 26, 2017
10d5ab0
#171 Minor bug fix in BinaryPayloadBuilder.add_string method for python3
dhoomakethu May 27, 2017
52770ff
Updated documentation
dhoomakethu May 27, 2017
1210425
Merge branch 'master' into dev
dhoomakethu May 31, 2017
939d832
Merge branch 'master' into dev
dhoomakethu Jun 8, 2017
ff79b7e
1. #179 fix error calculating response pdu length for read coil/discr…
dhoomakethu Jun 8, 2017
3166b6d
Enable debug logging for send packets
dhoomakethu Jun 8, 2017
488e5e3
#184 prepare for v1.3.1
dhoomakethu Jun 8, 2017
625ae60
Merge branch 'master' into dev
dhoomakethu Jun 17, 2017
bdcadf3
Make examples compatible withg python3
dhoomakethu Jun 17, 2017
4d96b95
Merge branch 'master' into dev
dhoomakethu Jun 22, 2017
f5f9f2c
fix #165, #174, #169, #175, #147, #146
dhoomakethu Jun 22, 2017
548f2a1
#184 updated changelog
dhoomakethu Jun 22, 2017
247657b
#142 move
dhoomakethu Jun 22, 2017
bd4c551
fix #186 +misc updates
dhoomakethu Jun 26, 2017
04ab5a0
Fixed obvious indentation error in InvalidResponseRecievedException c…
thozza Jul 12, 2017
00cba7e
#190 fix examples - callback-server, modbus-payload
dhoomakethu Jul 23, 2017
ed68895
#191 handle interframe timeout for baudrate >19200 on Modbus RTU
dhoomakethu Jul 23, 2017
7c57862
#201 Recover modbus server and client from previous errors
dhoomakethu Aug 4, 2017
dc42247
Merge master
dhoomakethu Aug 4, 2017
8167445
Update changelog
dhoomakethu Aug 4, 2017
7d9a717
#149 SerialServer could be stopped when running on a thread
dhoomakethu Aug 4, 2017
9307cfc
#149 update changelogs
dhoomakethu Aug 4, 2017
73e50f2
unit tests for #191, #149 , fix obvious server_start errors
dhoomakethu Aug 4, 2017
e977335
Add new skip_bytes method to BinaryPayloadDecoder to skip over bytes …
bje- Aug 19, 2017
406242c
update readme
dhoomakethu Aug 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pymodbus.egg-info/
.tox/
doc/api/epydoc/html/
.vscode/

.venv
__pycache__/
pymodbus/__pycache__/
pymodbus/client/__pycache__/
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

Version 1.3.2
------------------------------------------------------------
* ModbusSerialServer could now be stopped when running on a seperate thread.
* Fix issue with server and client where in the frame buffer had values from previous unsuccesful transaction
* Fix response length calculation for ModbusASCII protocol
* Fix response length calculation ReportSlaveIdResponse, DiagnosticStatusResponse
* Fix never ending transaction case when response is recieved without header and CRC
* Fix tests

Version 1.3.1
------------------------------------------------------------
* Recall socket recv until get a complete response
Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ like your device tested, I accept devices via mail or by IP address.
That said, the current work mainly involves polishing the library as
I get time doing such tasks as:

* Add CI support
* Make PEP-8 compatible and flake8 ready
* Fixing bugs/feature requests
* Architecture documentation
Expand All @@ -152,6 +151,10 @@ Use make to perform a range of activities
make tox run the tests on all Python versions
make clean cleanup all temporary files

------------------------------------------------------------
Contributing
------------------------------------------------------------
Just fork the repo and raise your PR against `dev` branch.

------------------------------------------------------------
License Information
Expand Down
6 changes: 4 additions & 2 deletions examples/common/callback-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer


#---------------------------------------------------------------------------#
# import the python libraries we need
#---------------------------------------------------------------------------#
Expand All @@ -31,7 +32,8 @@

#---------------------------------------------------------------------------#
# create your custom data block with callbacks
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#

class CallbackDataBlock(ModbusSparseDataBlock):
''' A datablock that stores the new value in memory
and passes the operation to a message queue for further
Expand All @@ -44,7 +46,7 @@ def __init__(self, devices, queue):
self.devices = devices
self.queue = queue

values = {k:0 for k in devices.iterkeys()}
values = {k:0 for k in devices.keys()}
values[0xbeef] = len(values) # the number of devices
super(CallbackDataBlock, self).__init__(values)

Expand Down
2 changes: 2 additions & 0 deletions examples/common/device-mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0x0001,/dev/ptyp0
0x0002,/dev/ptyp1
8 changes: 4 additions & 4 deletions examples/common/modbus-payload-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
# build your payload
#---------------------------------------------------------------------------#
builder = BinaryPayloadBuilder(endian=Endian.Little)
builder.add_string('abcdefgh')
builder.add_32bit_float(22.34)
builder.add_16bit_uint(0x1234)
builder.add_8bit_int(0x12)
# builder.add_string('abcdefgh')
# builder.add_32bit_float(22.34)
# builder.add_16bit_uint(4660)
# builder.add_8bit_int(18)
builder.add_bits([0,1,0,1,1,0,1,0])

#---------------------------------------------------------------------------#
Expand Down
15 changes: 10 additions & 5 deletions examples/common/modbus-payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.payload import BinaryPayloadBuilder
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from pymodbus.compat import iteritems

#---------------------------------------------------------------------------#
# configure the client logging
Expand All @@ -34,13 +35,15 @@
# - a 8 byte string 'abcdefgh'
# - a 32 bit float 22.34
# - a 16 bit unsigned int 0x1234
# - another 16 bit unsigned int 0x5678
# - an 8 bit int 0x12
# - an 8 bit bitstring [0,1,0,1,1,0,1,0]
#---------------------------------------------------------------------------#
builder = BinaryPayloadBuilder(endian=Endian.Big)
builder.add_string('abcdefgh')
builder.add_32bit_float(22.34)
builder.add_16bit_uint(0x1234)
builder.add_16bit_uint(0x5678)
builder.add_8bit_int(0x12)
builder.add_bits([0,1,0,1,1,0,1,0])
payload = builder.build()
Expand All @@ -57,6 +60,7 @@
# - a 8 byte string 'abcdefgh'
# - a 32 bit float 22.34
# - a 16 bit unsigned int 0x1234
# - another 16 bit unsigned int which we will ignore
# - an 8 bit int 0x12
# - an 8 bit bitstring [0,1,0,1,1,0,1,0]
#---------------------------------------------------------------------------#
Expand All @@ -68,15 +72,16 @@
'string': decoder.decode_string(8),
'float': decoder.decode_32bit_float(),
'16uint': decoder.decode_16bit_uint(),
'ignored': decoder.skip_bytes(2),
'8int': decoder.decode_8bit_int(),
'bits': decoder.decode_bits(),
}

print "-" * 60
print "Decoded Data"
print "-" * 60
for name, value in decoded.iteritems():
print ("%s\t" % name), value
print("-" * 60)
print("Decoded Data")
print("-" * 60)
for name, value in iteritems(decoded):
print ("%s\t" % name, value)

#---------------------------------------------------------------------------#
# close the client
Expand Down
11 changes: 8 additions & 3 deletions examples/common/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging, os
from time import time
from multiprocessing import log_to_stderr
from pymodbus.client.sync import ModbusTcpClient
# from pymodbus.client.sync import ModbusTcpClient
from pymodbus.client.sync import ModbusSerialClient

#---------------------------------------------------------------------------#
Expand Down Expand Up @@ -61,9 +61,10 @@ def single_client_test(host, cycles):
client = ModbusSerialClient(method="rtu", port="/dev/ttyp0", baudrate=9600)
while count < cycles:
with _thread_lock:
result = client.read_holding_registers(10, 1, unit=1).getRegister(0)
client.read_holding_registers(10, 1, unit=1).registers[0]
count += 1
except: logger.exception("failed to run test successfully")
except:
logger.exception("failed to run test successfully")
logger.debug("finished worker: %d" % os.getpid())

#---------------------------------------------------------------------------#
Expand All @@ -73,6 +74,10 @@ def single_client_test(host, cycles):
# threads that was specified. We then start all the threads and block on
# them to finish. This may need to switch to another mechanism to signal
# finished as the process/thread start up/shut down may skew the test a bit.

# RTU 32 requests/second @9600
# TCP 31430 requests/second

#---------------------------------------------------------------------------#
args = (host, int(cycles * 1.0 / workers))
procs = [Worker(target=single_client_test, args=args) for _ in range(workers)]
Expand Down
5 changes: 4 additions & 1 deletion pymodbus/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ def __init__(self, method='ascii', **kwargs):
self.timeout = kwargs.get('timeout', Defaults.Timeout)
if self.method == "rtu":
self._last_frame_end = 0.0
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate
if self.baudrate > 19200:
self._silent_interval = 1.75/1000 # ms
else:
self._silent_interval = 3.5 * (1 + 8 + 2) / self.baudrate

@staticmethod
def __implementation(method):
Expand Down
40 changes: 37 additions & 3 deletions pymodbus/diag_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def get_response_pdu_size(self):
return 1 + 2 + 2 * len(self.message)



class DiagnosticStatusResponse(ModbusResponse):
'''
This is a base class for all of the diagnostic response functions
Expand Down Expand Up @@ -118,7 +117,11 @@ def decode(self, data):

:param data: The data to decode into the function code
'''
self.sub_function_code, self.message = struct.unpack('>HH', data)
word_len = len(data)//2
if len(data) % 2:
word_len += 1
data = struct.unpack('>' + 'H'*word_len, data)
self.sub_function_code, self.message = data[0], data[1:]


class DiagnosticStatusSimpleRequest(DiagnosticStatusRequest):
Expand Down Expand Up @@ -708,6 +711,23 @@ class GetClearModbusPlusRequest(DiagnosticStatusSimpleRequest):
'''
sub_function_code = 0x0015

def __init__(self, **kwargs):
super(GetClearModbusPlusRequest, self).__init__(**kwargs)

def get_response_pdu_size(self):
"""
Returns a series of 54 16-bit words (108 bytes) in the data field of the response
(this function differs from the usual two-byte length of the data field). The data
contains the statistics for the Modbus Plus peer processor in the slave device.
Func_code (1 byte) + Sub function code (2 byte) + Operation (2 byte) + Data (108 bytes)
:return:
"""
if self.message == ModbusPlusOperation.GetStatistics:
data = 2 + 108 # byte count(2) + data (54*2)
else:
data = 0
return 1 + 2 + 2 + 2+ data

def execute(self, *args):
''' Execute the diagnostic request on the given device

Expand All @@ -716,9 +736,23 @@ def execute(self, *args):
message = None # the clear operation does not return info
if self.message == ModbusPlusOperation.ClearStatistics:
_MCB.Plus.reset()
else: message = _MCB.Plus.encode()
message = self.message
else:
message = [self.message]
message += _MCB.Plus.encode()
return GetClearModbusPlusResponse(message)

def encode(self):
'''
Base encoder for a diagnostic response
we encode the data set in self.message

:returns: The encoded packet
'''
packet = struct.pack('>H', self.sub_function_code)
packet += struct.pack('>H', self.message)
return packet


class GetClearModbusPlusResponse(DiagnosticStatusSimpleResponse):
'''
Expand Down
14 changes: 7 additions & 7 deletions pymodbus/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ def __init__(self, string=""):
ModbusException.__init__(self, message)


class InvalidResponseRecievedException(ModbusException):
class InvalidMessageRecievedException(ModbusException):
"""
Error resulting from invalid response received or decoded
"""

def __init__(self, string=""):
''' Initialize the exception

def __init__(self, string=""):
''' Initialize the exception
:param string: The message to append to the error
'''
message = "[Invalid Message] %s" % string
ModbusException.__init__(self, message)

:param string: The message to append to the error
'''
message = "[Invalid Response] %s" % string
ModbusException.__init__(self, message)

#---------------------------------------------------------------------------#
# Exported symbols
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/other_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def encode(self):
status = ModbusStatus.SlaveOn
else:
status = ModbusStatus.SlaveOff
length = len(self.identifier) + 2
length = len(self.identifier) + 1
packet = int2byte(length)
packet += self.identifier # we assume it is already encoded
packet += int2byte(status)
Expand Down
8 changes: 8 additions & 0 deletions pymodbus/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ def decode_string(self, size=1):
self._pointer += size
return self._payload[self._pointer - size:self._pointer]

def skip_bytes(self, nbytes):
''' Skip n bytes in the buffer

:param nbytes: The number of bytes to skip
'''
self._pointer += nbytes
return None

#---------------------------------------------------------------------------#
# Exported Identifiers
#---------------------------------------------------------------------------#
Expand Down
Loading