transfering chunk data with Modbus protocol

H

Thread Starter

Huskier

I want to transfer chunk data (e.g. 64KByte) with Modbus (RTU). But I have not found corresponding function code. Although the function code 0x03 can read hold registers, but at most 254 bytes are transfered though 0x03 function code. Because there is only one byte count in 0x03 function response frame.

Function 03: Read holding registers

The Modbus answer message starts with the slave device address and the function code 03. The next byte is the number of data bytes that follow. This value is two times the number of registers returned.

http://www.lammertbies.nl/comm/info/modbus.html

What should I do? Any ideas is appreciated!
 
Yes you are right, using ModBus you can not do it. Please write to me at autconATyahooDOTcomDOTar and tell me which type of devices you are using to send and receive data.

Best
 
Hi, I use Philips' 8051 with 32KByte extend flash as slave device, and the Master device is a PC. After finishing measure, I want to transfer all data from the 8051 slave to PC for further analysis. Could you give me some advices? Thanks in advance!
 
Modbus RTU messages are limited to 256 bytes in length, and it does not matter which function code you use, it is still 256 bytes/message.

One reason for this limitation is that the 16 bit CRC checksum used at the end of a Modbus RTU message is only designed for reliable error checking on a <= 256 byte message. You'll find that all communication protocols divide large messages into smaller messages to make sure the checksum used adheres to its specifications.

Modbus doesn't have an application layer to breakup long messages for you - unlike Kermit, SLiP, or PPP. You would have to do that yourself with Modbus or use someone's Modbus driver. Most HMI's have a Modbus driver that will sort that out for you. But!, unless you have an almost errorless communication path to your Modbus slave, a 64K data chunk is not going to be read reliably.
 
L
Given your context, Andrzej's suggestion to use modbus functions 0x14 Read File Record and 0x15 Write File Record is an excellent fit. I think most HMI don't support these, but you could support them with your own tools. I'd just define your FLASH as some documented but random file such as 0x2A47 and you could even get creative enough to reflash via Modbus. Of course you are STILL limited to reading/writing 245 bytes at a time, so you'd need to handle writting skilfully. If you want HMI to use func 3 for larger data space, one slightly ugly hack would be to define a 4x register to use to "page" in the extended memory.

Best regards
- Lynn August Linse, www.digi.com
Protocols over IP-network Blog http://iatips.com/blog
 
B
In Modbus serial (not 485) the max chunk you could send reliably is 1024 bytes, the max Modbus chunk will be 1040. In Modbus TCP the window size is almost always 8192 bytes (8k). This will make your reliable chunk size be 8207 bytes.

Any other protocol to transmit a bigger chunk will be extremely complex and unreliable. But do not implement them as registry read and write. It will be slow and in some networks they may timeout. Most implementations will have available memory for buffers; if they haven't, maybe they have DMA channels you could use.
 
Top