modbus RTU(RS484)数据包帧解码

时间:2015-06-30 06:18:11

标签: modbus

我从RTU设备和要监控的设备之间的RS485串行连接中捕获了协议分析仪日志。我是新手。我读过Modbus和RS485。发现每个帧都有Slave地址,功能代码,DATA和CRS,包含305个字符的开始和结束帧。我正在尝试解码协议分析器日志,但无法获得线索。请帮帮我。

这些是我需要理解的日志

=============================================== ==============

Record =          1         05.23.15  13:29:29.000000000  
                 RTS:OFF  DTR:OFF  CTS:OFF  DSR:OFF  CD:ON   
Record =          2  (DTE)  05.23.15  13:29:29.127439596  00  NUL 
Record =          3  (DTE)  05.23.15  13:29:29.127986496  37  7   
Record =          4  (DTE)  05.23.15  13:29:29.128741696  17  ETB 
Record =          5  (DTE)  05.23.15  13:29:29.129184396  ED  ... 
Record =          6  (DTE)  05.23.15  13:29:29.129757296  F2  ... 
Record =          7  (DTE)  05.23.15  13:29:29.130486496  FD  ... 
Record =          8  (DTE)  05.23.15  13:29:29.131007296  D5  ... 
Record =          9  (DCE)  05.23.15  13:29:29.559109485  91  ... 
Record =         10  (DCE)  05.23.15  13:29:29.559630385  10  DLE 
Record =         11  (DCE)  05.23.15  13:29:29.560151185  2F  /   
Record =         12  (DCE)  05.23.15  13:29:29.560678485  B0  ... 
Record =         13  (DCE)  05.23.15  13:29:29.561199385  00  NUL 
Record =         14  (DCE)  05.23.15  13:29:29.561720185  01  SOH 
Record =         15  (DCE)  05.23.15  13:29:29.562247485  02  STX 
Record =         16  (DCE)  05.23.15  13:29:29.562768385  00  NUL 
Record =         17  (DCE)  05.23.15  13:29:29.563289185  01  SOH 
Record =         18  (DCE)  05.23.15  13:29:29.563816485  0F  SI  
Record =         19  (DCE)  05.23.15  13:29:29.564337385  64  d  

Record =         20  (DTE)  05.23.15  13:29:29.707291982  00  NUL 
Record =         21  (DTE)  05.23.15  13:29:29.707838882  37  7   
Record =         22  (DTE)  05.23.15  13:29:29.708594082  17  ETB 
Record =         23  (DTE)  05.23.15  13:29:29.709036682  ED  ... 
Record =         24  (DTE)  05.23.15  13:29:29.709609682  F2  ... 
Record =         25  (DTE)  05.23.15  13:29:29.710338782  FD  ... 
Record =         26  (DTE)  05.23.15  13:29:29.710859682  D5  ... 
Record =         27  (DCE)  05.23.15  13:29:30.142926671  91  ... 
Record =         28  (DCE)  05.23.15  13:29:30.143447471  10  DLE 
Record =         29  (DCE)  05.23.15  13:29:30.143974871  2F  /   
Record =         30  (DCE)  05.23.15  13:29:30.144495671  B0  ... 
Record =         31  (DCE)  05.23.15  13:29:30.145016471  00  NUL 
Record =         32  (DCE)  05.23.15  13:29:30.145543871  01  SOH 
Record =         33  (DCE)  05.23.15  13:29:30.146064671  02  STX 
Record =         34  (DCE)  05.23.15  13:29:30.146585471  00  NUL 
Record =         35  (DCE)  05.23.15  13:29:30.147112871  01  SOH 
Record =         36  (DCE)  05.23.15  13:29:30.147633671  0F  SI  
Record =         37  (DCE)  05.23.15  13:29:30.148154470  64  d


Record =         38  (DTE)  05.23.15  13:29:30.287254967  00  NUL 

Record =         39  (DTE)  05.23.15  13:29:30.287801867  37  7 

=============================================================

1 个答案:

答案 0 :(得分:0)

查看时间戳,这似乎是一条信息: 91 10 2F B0 00 01 02 00 01 0F 64。它实际上在您的日志中出现两次。

解释应该是:

  • 91从属地址(145 dec)
  • 10功能代码(16 dec)=写寄存器
  • 2F起始地址(最高有效字节)
  • B0起始地址(最低有效字节)
  • 00寄存器数量(最高有效字节)
  • 01寄存器数量(最低有效字节)
  • 02字节数(随后是2个字节)
  • 00数据(最重要的字节)
  • 01数据(最低有效字节)
  • 0F CRC(校验和)
  • 64 CRC(校验和)

这是从主设备(计算机)到从设备(仪器)的消息。基本上它说:在带有从机地址145的仪器上写一个寄存器。寄存器地址是2FB0(十六进制),数据值是0001(十六进制)。

我已经写过如何在Python Minimalmodbus模块的文档中解释Modbus RTU消息:

仪器文档中描述了2FB0(十六进制)寄存器的信息。