file_message — File Modbus Messages

API Documentation

File Record Read/Write Messages

Currently none of these messages are implemented

class pymodbus.file_message.FileRecord(**kwargs)

Represents a file record and its relevant data.

__eq__(relf)

Compares the left object to the right

__init__(**kwargs)

Initializes a new instance

Params reference_type:
 Defaults to 0x06 (must be)
Params file_number:
 Indicates which file number we are reading
Params record_number:
 Indicates which record in the file
Params record_data:
 The actual data of the record
Params record_length:
 The length in registers of the record
Params response_length:
 The length in bytes of the record
__ne__(relf)

Compares the left object to the right

__repr__()

Gives a representation of the file record

class pymodbus.file_message.ReadFileRecordRequest(records=None, **kwargs)

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 registers.

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 (non-contiguous), but the references within each group must be sequential. Each group is defined in a seperate ‘sub-request’ field that contains seven bytes:

The reference type: 1 byte (must be 0x06)
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: 235 bytes.

__init__(records=None, **kwargs)

Initializes a new instance

Parameters:records – The file record requests to be read
decode(data)

Decodes the incoming request

Parameters:data – The data to decode into the address
encode()

Encodes the request packet

Returns:The byte encoded packet
execute(context)

Run a read exeception status request against the store

Parameters:context – The datastore to request from
Returns:The populated response
class pymodbus.file_message.ReadFileRecordResponse(records=None, **kwargs)

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 ‘sub-response’ contains a field that shows its own byte count.

__init__(records=None, **kwargs)

Initializes a new instance

Parameters:records – The requested file records
decode(data)

Decodes a the response

Parameters:data – The packet data to decode
encode()

Encodes the response

Returns:The byte encoded message
class pymodbus.file_message.WriteFileRecordRequest(records=None, **kwargs)

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.

__init__(records=None, **kwargs)

Initializes a new instance

Parameters:records – The file record requests to be read
decode(data)

Decodes the incoming request

Parameters:data – The data to decode into the address
encode()

Encodes the request packet

Returns:The byte encoded packet
execute(context)

Run the write file record request against the context

Parameters:context – The datastore to request from
Returns:The populated response
class pymodbus.file_message.WriteFileRecordResponse(records=None, **kwargs)

The normal response is an echo of the request.

__init__(records=None, **kwargs)

Initializes a new instance

Parameters:records – The file record requests to be read
decode(data)

Decodes the incoming request

Parameters:data – The data to decode into the address
encode()

Encodes the response

Returns:The byte encoded message
class pymodbus.file_message.ReadFifoQueueRequest(address=0, **kwargs)

This function code allows to read the contents of a First-In-First-Out (FIFO) queue of register in a remote device. The function returns a count of the registers in the queue, followed by the queued data. Up to 32 registers can be read: the count, plus up to 31 queued data registers.

The queue count register is returned first, followed by the queued data registers. The function reads the queue contents, but does not clear them.

__init__(address=0, **kwargs)

Initializes a new instance

Parameters:address – The fifo pointer address (0x0000 to 0xffff)
decode(data)

Decodes the incoming request

Parameters:data – The data to decode into the address
encode()

Encodes the request packet

Returns:The byte encoded packet
execute(context)

Run a read exeception status request against the store

Parameters:context – The datastore to request from
Returns:The populated response
class pymodbus.file_message.ReadFifoQueueResponse(values=None, **kwargs)

In a normal response, the byte count shows the quantity of bytes to follow, including the queue count bytes and value register bytes (but not including the error check field). The queue count is the quantity of data registers in the queue (not including the count register).

If the queue count exceeds 31, an exception response is returned with an error code of 03 (Illegal Data Value).

__init__(values=None, **kwargs)

Initializes a new instance

Parameters:values – The list of values of the fifo to return
classmethod calculateRtuFrameSize(buffer)

Calculates the size of the message

Parameters:buffer – A buffer containing the data that have been received.
Returns:The number of bytes in the response.
decode(data)

Decodes a the response

Parameters:data – The packet data to decode
encode()

Encodes the response

Returns:The byte encoded message