events — Events Used in PyModbus

Module author: Galen Collins <bashwork@gmail.com>

Section author: Galen Collins <bashwork@gmail.com>

API Documentation

Modbus Remote Events

An event byte returned by the Get Communications Event Log function can be any one of four types. The type is defined by bit 7 (the high-order bit) in each byte. It may be further defined by bit 6.

class pymodbus.events.ModbusEvent
decode(event)

Decodes the event message to its status bits

Parameters:event – The event to decode
encode()

Encodes the status bits to an event message

Returns:The encoded event message
class pymodbus.events.RemoteReceiveEvent(**kwargs)

Remote device MODBUS Receive Event

The remote device stores this type of event byte when a query message is received. It is stored before the remote device processes the message. This event is defined by bit 7 set to logic ‘1’. The other bits will be set to a logic ‘1’ if the corresponding condition is TRUE. The bit layout is:

Bit Contents 
----------------------------------
0   Not Used 
2   Not Used 
3   Not Used 
4   Character Overrun 
5   Currently in Listen Only Mode 
6   Broadcast Receive
7   1
decode(event)

Decodes the event message to its status bits

Parameters:event – The event to decode
encode()

Encodes the status bits to an event message

Returns:The encoded event message
class pymodbus.events.RemoteSendEvent(**kwargs)

Remote device MODBUS Send Event The remote device stores this type of event byte when it finishes processing a request message. It is stored if the remote device returned a normal or exception response, or no response.

This event is defined by bit 7 set to a logic ‘0’, with bit 6 set to a ‘1’. The other bits will be set to a logic ‘1’ if the corresponding condition is TRUE. The bit layout is:

Bit Contents 
-----------------------------------------------------------
0   Read Exception Sent (Exception Codes 1-3) 
1   Slave Abort Exception Sent (Exception Code 4) 
2   Slave Busy Exception Sent (Exception Codes 5-6) 
3   Slave Program NAK Exception Sent (Exception Code 7) 
4   Write Timeout Error Occurred 
5   Currently in Listen Only Mode 
6   1 
7   0
decode(event)

Decodes the event message to its status bits

Parameters:event – The event to decode
encode()

Encodes the status bits to an event message

Returns:The encoded event message
class pymodbus.events.EnteredListenModeEvent

Remote device Entered Listen Only Mode

The remote device stores this type of event byte when it enters the Listen Only Mode. The event is defined by a content of 04 hex.

decode(event)

Decodes the event message to its status bits

Parameters:event – The event to decode
encode()

Encodes the status bits to an event message

Returns:The encoded event message
class pymodbus.events.CommunicationRestartEvent

Remote device Initiated Communication Restart

The remote device stores this type of event byte when its communications port is restarted. The remote device can be restarted by the Diagnostics function (code 08), with sub-function Restart Communications Option (code 00 01).

That function also places the remote device into a ‘Continue on Error’ or ‘Stop on Error’ mode. If the remote device is placed into ‘Continue on Error’ mode, the event byte is added to the existing event log. If the remote device is placed into ‘Stop on Error’ mode, the byte is added to the log and the rest of the log is cleared to zeros.

The event is defined by a content of zero.

decode(event)

Decodes the event message to its status bits

Parameters:event – The event to decode
encode()

Encodes the status bits to an event message

Returns:The encoded event message

Table Of Contents

Previous topic

file_message — File Modbus Messages

Next topic

pdu — Base Structures

This Page