pyModbus TCP服务器输入/输出流量监控

2024-09-24 02:14:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python的新手。对不起,如果这个问题听起来很傻的话。你知道吗

我使用pyModbus在BeagleBone Black上实现一个异步Modbus TCP服务器。它工作得很好,我能够连接客户端并从寄存器中检索值。你知道吗

我启动服务器时使用:

from pymodbus.server.async import StartTcpServer

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

我现在正在尝试实现一个服务器进出流量的监视器。 我需要绘制/记录来自客户端的所有请求和来自服务器的所有响应。你知道吗

有没有办法访问rx/tx缓冲区?你知道吗

谢谢你。你知道吗


Tags: from服务器客户端server寄存器identitymodbuspymodbus
1条回答
网友
1楼 · 发布于 2024-09-24 02:14:53

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

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.

相关问题 更多 >