MODBUS RTU 传输文件

File Transport Over MODBUS (FOM)

1. Use function code 0x17

2. Use relative address

3. Register description

Command Register (0x0000)

#define SOH 0x01    
#define STX 0x02    
#define EOT 0x04    
#define CA  0x18    
#define C   0x43    
#define NAK 0x15

Sequence Register (0x0001)
Data Register (0x0002~0x0401)

4. Sequence diagram

4.1 Write File
Write Command+Sequence+Data Register, Read Command Register by MODBUS 0x17 code

Master Slave Begin Write [0x17]SOH+Seq(0)::FileName+FileSize...192 Bytes C+Seq(0) Writing:normal [0x17]STX+Seq(>0)::raw bytes C+Seq(>0) Repeat until complete Writing:error [0x17]STX+Seq(>0)::raw bytes NACK+Seq(>0) Writing:abort [0x17]STX+Seq(>0)::raw bytes CA End Write [0x17]EOT+Seq(>0)::raw bytes(all zeros) CA Master Slave

4.2 Read File
Write Command+Sequence Register, Read Command+Sequence+Data Register by MODBUS 0x17 code

Master Slave Begin read [0x17]C+Seq(0)+FileName... SOH+Seq(0)::FileName+FileSize...192 Bytes Reading:normal [0x17]C+prevSeq(>0) STX+Seq(>0)::192 raw bytes Repeat until complete Reading:error [0x17]NAK+prevSeq(>0) STX+prevSeq(>0)::192 raw bytes Reading:abort [0x17]CA EOT+Seq(>0)::192 raw bytes(all zeros) End read [0x17]C+prevSeq(>0) EOT+Seq(>0)::raw bytes(all zeros) Master Slave

你可能感兴趣的:(协议,modbus)