Skip to content

Commit efb90fb

Browse files
authored
Merge pull request #541 from riptideio/revert-536-use_hexlify_packets
Revert "Refactor/DRY: use `use_hexlify_packets`"
2 parents 69f2f00 + 054b191 commit efb90fb

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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.utilities import hexlify_packets
10+
from pymodbus.compat import byte2int
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: " + hexlify_packets(packet))
140+
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in 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: " + hexlify_packets(data))
149+
_logger.debug("recv: " + " ".join([hex(byte2int(x)) for x in 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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pymodbus.client.asynchronous.mixins import (AsyncModbusClientMixin,
1919
AsyncModbusSerialClientMixin)
2020
from pymodbus.exceptions import ConnectionException
21-
from pymodbus.utilities import hexlify_packets
21+
from pymodbus.compat import byte2int
2222

2323
LOGGER = logging.getLogger(__name__)
2424

@@ -74,7 +74,7 @@ def on_receive(self, *args):
7474

7575
if not data:
7676
return
77-
LOGGER.debug("recv: " + hexlify_packets(data))
77+
LOGGER.debug("recv: " + " ".join([hex(byte2int(x)) for x in data]))
7878
unit = self.framer.decode_data(data).get("unit", 0)
7979
self.framer.processIncomingPacket(data, self._handle_response, unit=unit)
8080

@@ -86,7 +86,7 @@ def execute(self, request=None):
8686
"""
8787
request.transaction_id = self.transaction.getNextTID()
8888
packet = self.framer.buildPacket(request)
89-
LOGGER.debug("send: " + hexlify_packets(packet))
89+
LOGGER.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
9090
self.stream.write(packet)
9191
return self._build_response(request.transaction_id)
9292

@@ -174,7 +174,7 @@ def callback(*args):
174174
if waiting:
175175
data = self.stream.connection.read(waiting)
176176
LOGGER.debug(
177-
"recv: " + hexlify_packets(data))
177+
"recv: " + " ".join([hex(byte2int(x)) for x in data]))
178178
unit = self.framer.decode_data(data).get("uid", 0)
179179
self.framer.processIncomingPacket(
180180
data,
@@ -185,7 +185,7 @@ def callback(*args):
185185
break
186186

187187
packet = self.framer.buildPacket(request)
188-
LOGGER.debug("send: " + hexlify_packets(packet))
188+
LOGGER.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
189189
self.stream.write(packet, callback=callback)
190190
f = self._build_response(request.transaction_id)
191191
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.utilities import hexlify_packets
43+
from pymodbus.compat import byte2int
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: " + hexlify_packets(packet))
112+
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
113113
self.transport.write(packet)
114114
return self._buildResponse(request.transaction_id)
115115

0 commit comments

Comments
 (0)