Skip to content

Commit 524ed34

Browse files
authored
Merge branch 'dev' into fix-533
2 parents 03b732c + da6ab36 commit 524ed34

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

examples/common/synchronous_client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
print result
1515
"""
1616
# --------------------------------------------------------------------------- #
17-
# import the various server implementations
17+
# import the various client implementations
1818
# --------------------------------------------------------------------------- #
1919
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
2020
# from pymodbus.client.sync import ModbusUdpClient as ModbusClient
@@ -104,12 +104,13 @@ def run_sync_client():
104104
rq = client.write_coil(0, True, unit=UNIT)
105105
rr = client.read_coils(0, 1, unit=UNIT)
106106
assert(not rq.isError()) # test that we are not an error
107+
assert(not rr.isError()) # test that we are not an error
107108
assert(rr.bits[0] == True) # test the expected value
108109

109110
log.debug("Write to multiple coils and read back- test 1")
110111
rq = client.write_coils(1, [True]*8, unit=UNIT)
111-
assert(not rq.isError()) # test that we are not an error
112112
rr = client.read_coils(1, 21, unit=UNIT)
113+
assert(not rq.isError()) # test that we are not an error
113114
assert(not rr.isError()) # test that we are not an error
114115
resp = [True]*21
115116

@@ -124,27 +125,30 @@ def run_sync_client():
124125
rq = client.write_coils(1, [False]*8, unit=UNIT)
125126
rr = client.read_coils(1, 8, unit=UNIT)
126127
assert(not rq.isError()) # test that we are not an error
128+
assert(not rr.isError()) # test that we are not an error
127129
assert(rr.bits == [False]*8) # test the expected value
128130

129131
log.debug("Read discrete inputs")
130132
rr = client.read_discrete_inputs(0, 8, unit=UNIT)
131-
assert(not rq.isError()) # test that we are not an error
133+
assert(not rr.isError()) # test that we are not an error
132134

133135
log.debug("Write to a holding register and read back")
134136
rq = client.write_register(1, 10, unit=UNIT)
135137
rr = client.read_holding_registers(1, 1, unit=UNIT)
136138
assert(not rq.isError()) # test that we are not an error
139+
assert(not rr.isError()) # test that we are not an error
137140
assert(rr.registers[0] == 10) # test the expected value
138141

139142
log.debug("Write to multiple holding registers and read back")
140143
rq = client.write_registers(1, [10]*8, unit=UNIT)
141144
rr = client.read_holding_registers(1, 8, unit=UNIT)
142145
assert(not rq.isError()) # test that we are not an error
146+
assert(not rr.isError()) # test that we are not an error
143147
assert(rr.registers == [10]*8) # test the expected value
144148

145149
log.debug("Read input registers")
146150
rr = client.read_input_registers(1, 8, unit=UNIT)
147-
assert(not rq.isError()) # test that we are not an error
151+
assert(not rr.isError()) # test that we are not an error
148152

149153
arguments = {
150154
'read_address': 1,
@@ -156,6 +160,7 @@ def run_sync_client():
156160
rq = client.readwrite_registers(unit=UNIT, **arguments)
157161
rr = client.read_holding_registers(1, 8, unit=UNIT)
158162
assert(not rq.isError()) # test that we are not an error
163+
assert(not rr.isError()) # test that we are not an error
159164
assert(rq.registers == [20]*8) # test the expected value
160165
assert(rr.registers == [20]*8) # test the expected value
161166

pymodbus/client/asynchronous/async_io/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import ssl
88
from pymodbus.exceptions import ConnectionException
99
from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin
10-
from pymodbus.compat import byte2int
10+
from pymodbus.utilities import hexlify_packets
1111
from pymodbus.transaction import FifoTransactionManager
1212
import logging
1313

@@ -137,7 +137,7 @@ def _execute(self, request, **kwargs):
137137
"""
138138
request.transaction_id = self.transaction.getNextTID()
139139
packet = self.framer.buildPacket(request)
140-
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
140+
_logger.debug("send: " + hexlify_packets(packet))
141141
self.write_transport(packet)
142142
return self._buildResponse(request.transaction_id)
143143

@@ -146,7 +146,7 @@ def _dataReceived(self, data):
146146
147147
:param data: The data returned from the server
148148
'''
149-
_logger.debug("recv: " + " ".join([hex(byte2int(x)) for x in data]))
149+
_logger.debug("recv: " + hexlify_packets(data))
150150
unit = self.framer.decode_data(data).get("unit", 0)
151151
self.framer.processIncomingPacket(data, self._handleResponse, unit=unit)
152152

pymodbus/client/asynchronous/tornado/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from pymodbus.client.asynchronous.mixins import (AsyncModbusClientMixin,
2020
AsyncModbusSerialClientMixin)
21+
2122
from pymodbus.compat import byte2int
2223
from pymodbus.exceptions import (ConnectionException,
2324
ModbusIOException,
@@ -26,6 +27,7 @@
2627
ModbusTransactionState)
2728
from pymodbus.constants import Defaults
2829

30+
2931
LOGGER = logging.getLogger(__name__)
3032

3133

@@ -80,7 +82,7 @@ def on_receive(self, *args):
8082

8183
if not data:
8284
return
83-
LOGGER.debug("recv: " + " ".join([hex(byte2int(x)) for x in data]))
85+
LOGGER.debug("recv: " + hexlify_packets(data))
8486
unit = self.framer.decode_data(data).get("unit", 0)
8587
self.framer.processIncomingPacket(data, self._handle_response, unit=unit)
8688

@@ -92,7 +94,7 @@ def execute(self, request=None):
9294
"""
9395
request.transaction_id = self.transaction.getNextTID()
9496
packet = self.framer.buildPacket(request)
95-
LOGGER.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
97+
LOGGER.debug("send: " + hexlify_packets(packet))
9698
self.stream.write(packet)
9799
return self._build_response(request.transaction_id)
98100

@@ -180,7 +182,7 @@ def callback(*args):
180182
if waiting:
181183
data = self.stream.connection.read(waiting)
182184
LOGGER.debug(
183-
"recv: " + " ".join([hex(byte2int(x)) for x in data]))
185+
"recv: " + hexlify_packets(data))
184186
unit = self.framer.decode_data(data).get("uid", 0)
185187
self.framer.processIncomingPacket(
186188
data,
@@ -191,7 +193,7 @@ def callback(*args):
191193
break
192194

193195
packet = self.framer.buildPacket(request)
194-
LOGGER.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
196+
LOGGER.debug("send: " + hexlify_packets(packet))
195197
self.stream.write(packet, callback=callback)
196198
f = self._build_response(request.transaction_id)
197199
return f

pymodbus/client/asynchronous/twisted/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def process():
4040
from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin
4141
from pymodbus.transaction import FifoTransactionManager, DictTransactionManager
4242
from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer
43-
from pymodbus.compat import byte2int
43+
from pymodbus.utilities import hexlify_packets
4444
from twisted.python.failure import Failure
4545

4646

@@ -109,7 +109,7 @@ def execute(self, request):
109109
"""
110110
request.transaction_id = self.transaction.getNextTID()
111111
packet = self.framer.buildPacket(request)
112-
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
112+
_logger.debug("send: " + hexlify_packets(packet))
113113
self.transport.write(packet)
114114
return self._buildResponse(request.transaction_id)
115115

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
license='BSD-3-Clause',
6969
packages=find_packages(exclude=['examples', 'test']),
7070
exclude_package_data={'': ['examples', 'test', 'tools', 'doc']},
71-
py_modules=['ez_setup'],
7271
platforms=['Linux', 'Mac OS X', 'Win'],
7372
include_package_data=True,
7473
zip_safe=True,

0 commit comments

Comments
 (0)