pyModbus-TCPServer输入/输出流量监视器

问题描述 投票:0回答:1

我是python的新手。抱歉,这个问题听起来很傻。

我正在使用pyModbus在BeagleBone Black上实现异步Modbus TCP服务器。它运作良好,我能够与客户端连接并从寄存器中检索值。

我用以下命令启动服务器:

from pymodbus.server.async import StartTcpServer

StartTcpServer(context, identity=identity, address=("0.0.0.0", 502))

我现在正在尝试实现对进出服务器的流量的监控。我需要绘制/记录来自客户端的所有请求以及来自服务器的所有响应。

是否有任何方法可以访问rx / tx缓冲区?

谢谢。

python modbus tcpserver modbus-tcp pymodbus
1个回答
0
投票

您可以按如下所示为Modbus服务器启用logging作为调试模式:

import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s'
          ' %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)

Here's the original example.

© www.soinside.com 2019 - 2024. All rights reserved.