You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pymodbus读取华为SDongleA-05光伏数据失败求助

华为光伏电站Modbus读取问题:mbpoll成功但pymodbus失败

我尝试从搭载Huawei SDongleA-05加密狗的华为光伏电站Modbus中读取用电、发电及电网交互数据。使用mbpoll命令可成功获取数据,但用pymodbus编写的Python代码却读取失败。

成功的mbpoll操作

执行命令

mbpoll -m tcp -a 1 -r 32000 -c 2 192.168.0.101

返回结果

[32000]: 0
[32001]: 6
-- Polling slave 1... Ctrl-C to stop)

失败的pymodbus测试

Python测试代码

from pymodbus.client.tcp import ModbusTcpClient
import logging

# 启用调试日志
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

# 设置连接
client = ModbusTcpClient('192.168.0.101', port=502)

if client.connect():
    # 读取保持寄存器32000和32001
    result = client.read_holding_registers(32000, 2, unit=1)

    if not result.isError():
        print("寄存器32000:", result.registers[0])
        print("寄存器32001:", result.registers[1])
    else:
        print("Modbus错误:", result)

    client.close()
else:
    print("错误:无法连接到逆变器")

执行结果

python3 testhuawei.py

DEBUG:pymodbus.logging:Connection to Modbus server established. Socket ('192.168.0.110', 60006)
DEBUG:pymodbus.logging:Current transaction state - IDLE
DEBUG:pymodbus.logging:Running transaction 1
DEBUG:pymodbus.logging:SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x7d 0x0 0x0 0x2
DEBUG:pymodbus.logging:New Transaction state "SENDING"
DEBUG:pymodbus.logging:Changing transaction state from "SENDING" to "WAITING FOR REPLY"
DEBUG:pymodbus.logging:Transaction failed. (Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received))
DEBUG:pymodbus.logging:Processing:
DEBUG:pymodbus.logging:Getting transaction 1
DEBUG:pymodbus.logging:Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
Modbus错误: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received)

请问有人知道问题出在哪里吗?提前感谢!


内容的提问来源于stack exchange,提问作者bojan gavrilovic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 20:35:22