Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/DRY: use use_hexlify_packets #536

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions pymodbus/client/asynchronous/async_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ssl
from pymodbus.exceptions import ConnectionException
from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin
from pymodbus.compat import byte2int
from pymodbus.utilities import hexlify_packets
from pymodbus.transaction import FifoTransactionManager
import logging

Expand Down Expand Up @@ -137,7 +137,7 @@ def _execute(self, request, **kwargs):
"""
request.transaction_id = self.transaction.getNextTID()
packet = self.framer.buildPacket(request)
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
_logger.debug("send: " + hexlify_packets(packet))
self.write_transport(packet)
return self._buildResponse(request.transaction_id)

Expand All @@ -146,7 +146,7 @@ def _dataReceived(self, data):

:param data: The data returned from the server
'''
_logger.debug("recv: " + " ".join([hex(byte2int(x)) for x in data]))
_logger.debug("recv: " + hexlify_packets(data))
unit = self.framer.decode_data(data).get("unit", 0)
self.framer.processIncomingPacket(data, self._handleResponse, unit=unit)

Expand Down
10 changes: 5 additions & 5 deletions pymodbus/client/asynchronous/tornado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pymodbus.client.asynchronous.mixins import (AsyncModbusClientMixin,
AsyncModbusSerialClientMixin)
from pymodbus.exceptions import ConnectionException
from pymodbus.compat import byte2int
from pymodbus.utilities import hexlify_packets

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -74,7 +74,7 @@ def on_receive(self, *args):

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

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

Expand Down Expand Up @@ -174,7 +174,7 @@ def callback(*args):
if waiting:
data = self.stream.connection.read(waiting)
LOGGER.debug(
"recv: " + " ".join([hex(byte2int(x)) for x in data]))
"recv: " + hexlify_packets(data))
unit = self.framer.decode_data(data).get("uid", 0)
self.framer.processIncomingPacket(
data,
Expand All @@ -185,7 +185,7 @@ def callback(*args):
break

packet = self.framer.buildPacket(request)
LOGGER.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
LOGGER.debug("send: " + hexlify_packets(packet))
self.stream.write(packet, callback=callback)
f = self._build_response(request.transaction_id)
return f
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/client/asynchronous/twisted/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def process():
from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin
from pymodbus.transaction import FifoTransactionManager, DictTransactionManager
from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer
from pymodbus.compat import byte2int
from pymodbus.utilities import hexlify_packets
from twisted.python.failure import Failure


Expand Down Expand Up @@ -109,7 +109,7 @@ def execute(self, request):
"""
request.transaction_id = self.transaction.getNextTID()
packet = self.framer.buildPacket(request)
_logger.debug("send: " + " ".join([hex(byte2int(x)) for x in packet]))
_logger.debug("send: " + hexlify_packets(packet))
self.transport.write(packet)
return self._buildResponse(request.transaction_id)

Expand Down