Skip to content

Commit c9e8d75

Browse files
authored
Merge pull request #329 from riptideio/pymodbus-repl
Pymodbus repl
2 parents 7a0ad56 + c201144 commit c9e8d75

19 files changed

+1581
-78
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
omit =
3+
pymodbus/repl/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ test/__pycache__/
3636
/doc/html/
3737
/doc/_build/
3838
.pytest_cache/
39+
/.pymodhis

.readthedocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ requirements_file: requirements-docs.txt
66
python:
77
extra_requirements:
88
- twisted
9+
- torndo
910
- documents
1011
version: 3.5

CHANGELOG.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
Version 2.0.0rc2
2+
-----------------------------------------------------------
3+
**Note This is a Major release and might affect your existing Async client implementation. Refer examples on how to use the latest async clients.**
4+
5+
* Async client implementation based on Tornado, Twisted and asyncio with backward compatibility support for twisted client.
6+
* Allow reusing existing[running] asyncio loop when creating async client based on asyncio.
7+
* Allow reusing address for Modbus TCP sync server.
8+
* Add support to install tornado as extra requirement while installing pymodbus.
9+
* Support Pymodbus REPL
10+
* Add support to python 3.7.
11+
* Bug fix and enhancements in examples.
12+
13+
114
Version 2.0.0rc1
215
-----------------------------------------------------------
316
**Note This is a Major release and might affect your existing Async client implementation. Refer examples on how to use the latest async clients.**
417

518
* Async client implementation based on Tornado, Twisted and asyncio
619

20+
721
Version 1.5.2
822
------------------------------------------------------------
923
* Fix serial client `is_socket_open` method

README.rst

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ Client Features
3434
* Full read/write protocol on discrete and register
3535
* Most of the extended protocol (diagnostic/file/pipe/setting/information)
3636
* TCP, UDP, Serial ASCII, Serial RTU, and Serial Binary
37-
* asynchronous(powered by twisted) and synchronous versions
37+
* asynchronous(powered by twisted/tornado/asyncio) and synchronous versions
3838
* Payload builder/decoder utilities
39+
* Pymodbus REPL for quick tests
3940

4041
------------------------------------------------------------
4142
Server Features
@@ -93,9 +94,21 @@ trace them. I get a lot of email and sometimes these requests
9394
get lost in the noise: http://groups.google.com/group/pymodbus or
9495
at gitter: https://gitter.im/pymodbus_dev/Lobby
9596

96-
------------------------------------------------------------
97+
============================================================
98+
Pymodbus REPL (Read Evaluate Procee Loop)
99+
============================================================
100+
Starting with Pymodbus 2.x, pymodbus library comes with handy
101+
Pymodbus REPL to quickly run the modbus clients in tcp/rtu modes.
102+
103+
Pymodbus REPL comes with many handy features such as payload decoder
104+
to directly retrieve the values in desired format and supports all
105+
the diagnostic function codes directly .
106+
107+
For more info on REPL refer `Pymodbus REPL <pymodbus/repl/README.md>`_
108+
109+
============================================================
97110
Installing
98-
------------------------------------------------------------
111+
============================================================
99112

100113
You can install using pip or easy install by issuing the following
101114
commands in a terminal window (make sure you have correct
@@ -104,15 +117,18 @@ permissions or a virtualenv currently running)::
104117
easy_install -U pymodbus
105118
pip install -U pymodbus
106119

107-
To Install pymodbus with twisted support run
108-
.. code-block:: python
120+
To Install pymodbus with twisted support run::
121+
109122
pip install -U pymodbus[twisted]
110123

111-
To Install pymodbus with tornado support run
124+
To Install pymodbus with tornado support run::
112125

113-
.. code-block:: python
114126
pip install -U pymodbus[tornado]
115127

128+
To Install pymodbus REPL::
129+
130+
pip install -U pymodbus[repl]
131+
116132
Otherwise you can pull the trunk source and install from there::
117133

118134
git clone git://github.com/bashwork/pymodbus.git
@@ -128,9 +144,9 @@ out all mentions of twisted. It should be noted that without twisted,
128144
one will only be able to run the synchronized version as the
129145
asynchronous versions uses twisted for its event loop.
130146

131-
------------------------------------------------------------
147+
============================================================
132148
Current Work In Progress
133-
------------------------------------------------------------
149+
============================================================
134150

135151
Since I don't have access to any live modbus devices anymore
136152
it is a bit hard to test on live hardware. However, if you would
@@ -166,14 +182,14 @@ Use make to perform a range of activities
166182
make tox run the tests on all Python versions
167183
make clean cleanup all temporary files
168184

169-
------------------------------------------------------------
185+
============================================================
170186
Contributing
171-
------------------------------------------------------------
187+
============================================================
172188
Just fork the repo and raise your PR against `dev` branch.
173189

174-
------------------------------------------------------------
190+
============================================================
175191
License Information
176-
------------------------------------------------------------
192+
============================================================
177193

178194
Pymodbus is built on top of code developed from/by:
179195
* Copyright (c) 2001-2005 S.W.A.C. GmbH, Germany.

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Welcome to PyModbus's documentation!
1212

1313
readme.rst
1414
changelog.rst
15+
repl.rst
1516
source/example/modules.rst
1617
source/library/modules.rst
1718

doc/repl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Pymodbus REPL
2+
=============
3+
4+
.. mdinclude:: ../pymodbus/repl/README.md

doc/source/library/pymodbus.repl.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
pymodbus\.repl package
2+
==========================
3+
4+
.. automodule:: pymodbus.repl
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
10+
Submodules
11+
----------
12+
13+
pymodbus\.repl\.client module
14+
-----------------------------------
15+
16+
.. automodule:: pymodbus.repl.client
17+
:members:
18+
:undoc-members:
19+
:show-inheritance:
20+
21+
pymodbus\.repl\.completer module
22+
-----------------------------------
23+
24+
.. automodule:: pymodbus.repl.completer
25+
:members:
26+
:undoc-members:
27+
:show-inheritance:
28+
29+
pymodbus\.repl\.helper module
30+
-----------------------------------
31+
32+
.. automodule:: pymodbus.repl.helper
33+
:members:
34+
:undoc-members:
35+
:show-inheritance:
36+
37+
38+
pymodbus\.repl\.main module
39+
-----------------------------------
40+
41+
.. automodule:: pymodbus.repl.main
42+
:members:
43+
:undoc-members:
44+
:show-inheritance:

doc/source/library/pymodbus.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Subpackages
1616
pymodbus.framer
1717
pymodbus.internal
1818
pymodbus.server
19+
pymodbus.repl
1920

2021

2122
Submodules

pymodbus/compat.py

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'''
1+
"""
22
Python 2.x/3.x Compatibility Layer
33
-------------------------------------------------
44
@@ -10,87 +10,68 @@
1010
1111
:copyright: Copyright 2013 by the Jinja team, see AUTHORS.
1212
:license: BSD, see LICENSE for details.
13-
'''
13+
"""
1414
import sys
15-
import struct
15+
import six
1616

17-
#---------------------------------------------------------------------------#
17+
# --------------------------------------------------------------------------- #
1818
# python version checks
19-
#---------------------------------------------------------------------------#
19+
# --------------------------------------------------------------------------- #
2020
PYTHON_VERSION = sys.version_info
21-
IS_PYTHON2 = PYTHON_VERSION[0] == 2
22-
IS_PYTHON3 = PYTHON_VERSION[0] == 3
23-
IS_PYPY = hasattr(sys, 'pypy_translation_info')
24-
IS_JYTHON = sys.platform.startswith('java')
21+
IS_PYTHON2 = six.PY2
22+
IS_PYTHON3 = six.PY3
23+
IS_PYPY = hasattr(sys, 'pypy_translation_info')
24+
IS_JYTHON = sys.platform.startswith('java')
2525

26-
#---------------------------------------------------------------------------#
27-
# python > 3.3 compatability layer
28-
#---------------------------------------------------------------------------#
29-
if not IS_PYTHON2:
30-
#-----------------------------------------------------------------------#
31-
# portable builtins
32-
#-----------------------------------------------------------------------#
33-
int2byte = lambda b: struct.pack('B', b)
34-
byte2int = lambda b: b
35-
unichr = chr
36-
range_type = range
37-
text_type = str
38-
string_types = (str,)
39-
iterkeys = lambda d: iter(d.keys())
40-
itervalues = lambda d: iter(d.values())
41-
iteritems = lambda d: iter(d.items())
42-
get_next = lambda x: x.__next__()
43-
44-
#-----------------------------------------------------------------------#
45-
# module renames
46-
#-----------------------------------------------------------------------#
47-
from io import BytesIO, StringIO
48-
NativeStringIO = StringIO
26+
# --------------------------------------------------------------------------- #
27+
# python > 3.3 compatibility layer
28+
# --------------------------------------------------------------------------- #
29+
# ----------------------------------------------------------------------- #
30+
# portable builtins
31+
# ----------------------------------------------------------------------- #
32+
int2byte = six.int2byte
33+
unichr = six.unichr
34+
range_type = six.moves.range
35+
text_type = six.string_types
36+
string_types = six.string_types
37+
iterkeys = six.iterkeys
38+
itervalues = six.itervalues
39+
iteritems = six.iteritems
40+
get_next = six.next
41+
unicode_string = six.u
4942

50-
ifilter = filter
51-
imap = map
52-
izip = zip
53-
intern = sys.intern
43+
NativeStringIO = six.StringIO
44+
ifilter = six.moves.filter
45+
imap = six.moves.map
46+
izip = six.moves.zip
47+
intern = six.moves.intern
5448

49+
if not IS_PYTHON2:
50+
# ----------------------------------------------------------------------- #
51+
# module renames
52+
# ----------------------------------------------------------------------- #
5553
import socketserver
5654

57-
#-----------------------------------------------------------------------#
55+
# ----------------------------------------------------------------------- #
5856
# decorators
59-
#-----------------------------------------------------------------------#
57+
# ----------------------------------------------------------------------- #
6058
implements_to_string = lambda x: x
6159

62-
#---------------------------------------------------------------------------#
60+
byte2int = lambda b: b
61+
# --------------------------------------------------------------------------- #
6362
# python > 2.5 compatability layer
64-
#---------------------------------------------------------------------------#
63+
# --------------------------------------------------------------------------- #
6564
else:
66-
#-----------------------------------------------------------------------#
67-
# portable builtins
68-
#-----------------------------------------------------------------------#
69-
int2byte = chr
70-
byte2int = ord
71-
unichr = unichr
72-
text_type = unicode
73-
range_type = xrange
74-
string_types = (str, unicode)
75-
iterkeys = lambda d: d.iterkeys()
76-
itervalues = lambda d: d.itervalues()
77-
iteritems = lambda d: d.iteritems()
78-
get_next = lambda x: x.next()
79-
80-
#-----------------------------------------------------------------------#
65+
byte2int = six.byte2int
66+
# ----------------------------------------------------------------------- #
8167
# module renames
82-
#-----------------------------------------------------------------------#
83-
from cStringIO import StringIO as BytesIO, StringIO
84-
NativeStringIO = BytesIO
85-
86-
from itertools import imap, izip, ifilter
87-
intern = intern
8868

69+
# ----------------------------------------------------------------------- #
8970
import SocketServer as socketserver
9071

91-
#-----------------------------------------------------------------------#
72+
# ----------------------------------------------------------------------- #
9273
# decorators
93-
#-----------------------------------------------------------------------#
74+
# ----------------------------------------------------------------------- #
9475
def implements_to_string(klass):
9576
klass.__unicode__ = klass.__str__
9677
klass.__str__ = lambda x: x.__unicode__().encode('utf-8')

pymodbus/payload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pymodbus.utilities import unpack_bitstring
1515
from pymodbus.utilities import make_byte_string
1616
from pymodbus.exceptions import ParameterException
17-
17+
from pymodbus.compat import unicode_string
1818
# --------------------------------------------------------------------------- #
1919
# Logging
2020
# --------------------------------------------------------------------------- #
@@ -341,7 +341,7 @@ def _unpack_words(self, fstring, handle):
341341
pk = self._byteorder + 'H'
342342
handle = [pack(pk, p) for p in handle]
343343
handle = b''.join(handle)
344-
_logger.debug(handle)
344+
_logger.debug(unicode_string(handle))
345345
return handle
346346

347347
def reset(self):

0 commit comments

Comments
 (0)