【问题标题】:pyModbus - TCPServer in/out traffic monitorpyModbus - TCPServer 输入/输出流量监视器
【发布时间】:2019-12-19 11:27:31
【问题描述】:

我是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】:

    您可以启用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.

    【讨论】:

    • 谢谢 Benyamin,但要解析/记录的信息太多了。您将获得任何事件发生的条目。我真的只需要访问存储输入/输出消息的缓冲区。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-25
    • 2014-01-06
    • 1970-01-01
    相关资源
    最近更新 更多