Modbus Serial protocol messages are transmitted between a
master and slave devices over serial lines using the ASCII
or RTU transmission modes (Fig. 1). The messages have
three components: (i) slave address, (ii) Modbus application
protocol data unit (PDU), and (iii) an error checking field. The
slave address in a request message identifies the recipient;
the corresponding address in a response message identifies
the responding slave. A unicast message has an address in the
[1, 247] range that identifies an individual slave. A broadcast
message uses a slave address of zero. Values in the [248, 255]
range are reserved addresses.
The Modbus PDU has two fields, a one-byte function code
and function parameters (maximum 252 bytes). The function
code field in a request message specifies the operation
requested by the master; the corresponding field in the
response message is used to convey status information to
the master (e.g., error information when an exception occurs
in the slave device). The function parameters field contains
data pertaining to function invocation (request messages) or
function results (response messages)