modbus协议(⽂件读写)0x140x15
6.14 20 (0x14) Read File Record
This function code is used to perform a file record read. All Request Data Lengths are
provided in terms of number of bytes and all Record Lengths are provided in terms of
reference groupregisters.
A file is an organization of records. Each file contains 10000 records, addressed 0000 to
9999 decimal or 0X0000 to 0X270F. For example, record 12 is addressed as 12.
The function can read multiple groups of references. The groups can be separating (noncontiguous),
but the references within each group must be sequential.
Each group is defined in a separate ‘sub-request’ field that contains 7 bytes:
The reference type: 1 byte (must be specified as 6)
The File number: 2 bytes
The starting record number within the file: 2 bytes
The length of the record to be read: 2 bytes.
The quantity of registers to be read, combined with all other fields in the expected response,
must not exceed the allowable length of the MODBUS PDU : 253 bytes.
The normal response is a series of ‘sub-responses’, one for each ‘sub-request’. The byte
count field is the total combined count of bytes in all ‘sub-responses’. In addition, each ‘subresponse’
contains a field that shows its own byte count.
While it is allowed for the File Number to be in the range 1 to 0xFFFF, it should be noted that
interoperability with legacy equipment may be compromised if the File Number is greater than
10 (0x0A).
Here is an example of a request to read two groups of references from remote device:
ƒ Group 1 consists of two registers from file 4, starting at register 1 (address 0001).
ƒ Group 2 consists of two registers from file 3, starting at register 9 (address 0009).
Group1 Group2⿊体部分
Request: 0x14(功能码) 0x0E(后⾯字节个数,不包含CRC) 06(引⽤类型) 00 04(⽂件号) 00 01(⽂件记录号) 00 02(⽂件记录长度,2个寄存器长度) 06 00 03(⽂件号) 00 09(⽂件记录号) 00 02(⽂件记录长度,2个寄存器长度)
Reponse:14(功能码) 0x0C(后⾯字节个数,不包含CRC)) 0x05(group1的长度,后⾯) 06(引⽤类型) 0D FE 00 20(2个寄存器, 4个字节)
0x05(group2的长度,后⾯) 06(引⽤类型) 33 CD 00 40(2个寄存器,4个字节)
6.15 21 (0x15) Write File Record
This function code is used to perform a file record write. All Request Data Lengths are
provided in terms of number of bytes and all Record Lengths are provided in terms of the
number of 16-bit words.
A file is an organization of records. Each file contains 10000 records, addressed 0000 to
9999 decimal or 0X0000 to 0X270F. For example, record 12 is addressed as 12.
The function can write multiple groups of references. The groups can be separate, i.e. non–
contiguous, but the references within each group must be sequential.
Each group is defined in a separate ‘sub-request’ field that contains 7 bytes plus the data:
The reference type: 1 byte (must be specified as 6)
The file number: 2 bytes
The starting record number within the file: 2 bytes
The length of the record to be written: 2 bytes
The data to be written: 2 bytes per register.
The quantity of registers to be written, combined with all other fields in the request, must not
exceed the allowable length of the MODBUS PDU : 253bytes.
The normal response is an echo of the request.
While it is allowed for the File Number to be in the range 1 to 0xFFFF, it should be noted that
interoperability with legacy equipment may be compromised if the File Number is greater than
10 (0x0A).
Here is an example of a request to write one group of references into remote device:
y The group consists of three registers in file 4, starting at register 7 (address 0007).
Request: 0x15(功能码) 0x0D(后⾯数据长度,不包括CRC,13字节) 06(引⽤类型) 00 04(⽂件号) 00 07(⽂件⾥记录号) 00 03(记录长度,3个寄存器) 06 AF 04 BE 10 0D
Reponse: 0x15(功能码) 0x0D(后⾯数据长度,不包括CRC,13字节) 06(引⽤类型) 00 04(⽂件号) 00 07(⽂件⾥记录号) 00 03(记录长度,3个寄存器) 06 AF 04 BE 10 0D
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论