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

使用pymodbus读取LnT WL4440电表:Windows寄存器值异常、树莓派无响应问题求助

pymodbus读取LnT WL4440电表:Windows寄存器值异常、树莓派无响应问题求助

我现在在用Modbus RTU读取LnT的WL4440电表,先用ModScan做了测试,能正常拿到正确的数值——目标寄存器40140和40141显示的是非零的有效值。

但换成pymodbus之后就出问题了,分两种情况:

Windows环境下的问题

用pymodbus读取时,寄存器40140和40141读出来的结果都是0,和ModScan的结果完全不符。我已经开启了pymodbus的调试日志,里面记录了完整的通讯交互过程,但暂时没定位到问题点。

树莓派环境下的问题

在树莓派上运行同样的代码,直接报错无响应,终端输出如下:

gridinsight@GI-ED-01:~/edge_device $ bin/python main_read.py
True
DEBUG:pymodbus.logging:Current transaction state - IDLE
DEBUG:pymodbus.logging:Running transaction 0
DEBUG:pymodbus.logging:SEND: 0x1 0x3 0x9c 0xcd 0x0 0x1 0x3b 0xa5
DEBUG:pymodbus.logging:New Transaction state "SENDING"
DEBUG:pymodbus.logging:Changing transaction state from "SENDING" to "WAITING FOR REPLY"
DEBUG:pymodbus.logging:Changing transaction state from "WAITING FOR REPLY" to 
"PROCESSING REPLY"
DEBUG:pymodbus.logging:Processing: 0x1 0x3 0x2 0x0 0x0 0x0 0x0
DEBUG:pymodbus.logging:Frame check failed, ignoring!!
DEBUG:pymodbus.logging:Frame check failed, ignoring!!
DEBUG:pymodbus.logging:Short frame: 0x1 0x3 0x2 0x0 0x0 0x0 0x0 wait for more data
DEBUG:pymodbus.logging:Processing: 0x0 0x0 0x0
DEBUG:pymodbus.logging:Short frame: 0x0 0x0 0x0 wait for more data
DEBUG:pymodbus.logging:Getting transaction 0
DEBUG:pymodbus.logging:Changing transaction state from "PROCESSING REPLY" to 
"TRANSACTION_COMPLETE"
Modbus Error: [Input/Output] No Response received from the remote slave/Unable to 
decode response
gridinsight@GI-ED-01:~/edge_device $ 

我在Windows上使用的Python代码如下:

from pymodbus import framer
import logging
import logging.handlers as Handlers
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
from pymodbus.client import ModbusSerialClient


ip='192.168.1.25'
port = 1502
slave_id=1

#rtu_port = '/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0'
rtu_port = 'COM5'


rtu_client = ModbusSerialClient(port=rtu_port,framer=framer.FramerType.RTU,baudrate=9600,
timeout=3,parity='E',stopbits=1,handle_local_echo=False)
print(rtu_client.connect())

read_Data =rtu_client.read_holding_registers(address=40141,count=1,slave=1)
print(read_Data.registers)
rtu_client.close()

另外要说明的是,这套代码我用来读取Growwatt的光伏逆变器是完全正常的,所以应该不是代码的通用问题,大概率是和这个LnT电表的Modbus协议兼容或者通讯参数的问题?有没有遇到过类似情况的朋友能帮我分析下?

备注:内容来源于stack exchange,提问作者user137273

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.13 19:18:07