diag_message — Diagnostic Modbus Messages

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

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

API Documentation

Diagnostic Record Read/Write

These need to be tied into a the current server context or linked to the appropriate data

class pymodbus.diag_message.DiagnosticStatusRequest

This is a base class for all of the diagnostic request functions

decode(data)

Base decoder for a diagnostic request

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

Base encoder for a diagnostic response we encode the data set in self.message

Returns:The encoded packet
class pymodbus.diag_message.DiagnosticStatusResponse

This is a base class for all of the diagnostic response functions

It works by performing all of the encoding and decoding of variable data and lets the higher classes define what extra data to append and how to execute a request

decode(data)

Base decoder for a diagnostic response

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

Base encoder for a diagnostic response we encode the data set in self.message

Returns:The encoded packet
class pymodbus.diag_message.DiagnosticStatusSimpleRequest(data=0)

A large majority of the diagnostic functions are simple status request functions. They work by sending 0x0000 as data and their function code and they are returned 2 bytes of data.

If a function inherits this, they only need to implement the execute method

execute(*args)

Base function to raise if not implemented

class pymodbus.diag_message.DiagnosticStatusSimpleResponse(data)

A large majority of the diagnostic functions are simple status request functions. They work by sending 0x0000 as data and their function code and they are returned 2 bytes of data.

class pymodbus.diag_message.ReturnQueryDataRequest(message=0)

The data passed in the request data field is to be returned (looped back) in the response. The entire response message should be identical to the request.

execute(*args)

Executes the loopback request (builds the response)

Returns:The populated loopback response message
class pymodbus.diag_message.ReturnQueryDataResponse(message=0)

The data passed in the request data field is to be returned (looped back) in the response. The entire response message should be identical to the request.

class pymodbus.diag_message.RestartCommunicationsOptionRequest(toggle=False)

The remote device serial line port must be initialized and restarted, and all of its communications event counters are cleared. If the port is currently in Listen Only Mode, no response is returned. This function is the only one that brings the port out of Listen Only Mode. If the port is not currently in Listen Only Mode, a normal response is returned. This occurs before the restart is executed.

execute(*args)

Clear event log and restart

Returns:The initialized response message
class pymodbus.diag_message.RestartCommunicationsOptionResponse(toggle=False)

The remote device serial line port must be initialized and restarted, and all of its communications event counters are cleared. If the port is currently in Listen Only Mode, no response is returned. This function is the only one that brings the port out of Listen Only Mode. If the port is not currently in Listen Only Mode, a normal response is returned. This occurs before the restart is executed.

class pymodbus.diag_message.ReturnDiagnosticRegisterRequest(data=0)

The contents of the remote device’s 16-bit diagnostic register are returned in the response

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnDiagnosticRegisterResponse(data)

The contents of the remote device’s 16-bit diagnostic register are returned in the response

class pymodbus.diag_message.ChangeAsciiInputDelimiterRequest(data=0)

The character ‘CHAR’ passed in the request data field becomes the end of message delimiter for future messages (replacing the default LF character). This function is useful in cases of a Line Feed is not required at the end of ASCII messages.

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ChangeAsciiInputDelimiterResponse(data)

The character ‘CHAR’ passed in the request data field becomes the end of message delimiter for future messages (replacing the default LF character). This function is useful in cases of a Line Feed is not required at the end of ASCII messages.

class pymodbus.diag_message.ForceListenOnlyModeRequest(data=0)

Forces the addressed remote device to its Listen Only Mode for MODBUS communications. This isolates it from the other devices on the network, allowing them to continue communicating without interruption from the addressed remote device. No response is returned.

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ForceListenOnlyModeResponse

Forces the addressed remote device to its Listen Only Mode for MODBUS communications. This isolates it from the other devices on the network, allowing them to continue communicating without interruption from the addressed remote device. No response is returned.

This does not send a response

class pymodbus.diag_message.ClearCountersRequest(data=0)

The goal is to clear ll counters and the diagnostic register. Also, counters are cleared upon power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ClearCountersResponse(data)

The goal is to clear ll counters and the diagnostic register. Also, counters are cleared upon power-up

class pymodbus.diag_message.ReturnBusMessageCountRequest(data=0)

The response data field returns the quantity of messages that the remote device has detected on the communications systems since its last restart, clear counters operation, or power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnBusMessageCountResponse(data)

The response data field returns the quantity of messages that the remote device has detected on the communications systems since its last restart, clear counters operation, or power-up

class pymodbus.diag_message.ReturnBusCommunicationErrorCountRequest(data=0)

The response data field returns the quantity of CRC errors encountered by the remote device since its last restart, clear counter operation, or power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnBusCommunicationErrorCountResponse(data)

The response data field returns the quantity of CRC errors encountered by the remote device since its last restart, clear counter operation, or power-up

class pymodbus.diag_message.ReturnBusExceptionErrorCountRequest(data=0)

The response data field returns the quantity of modbus exception responses returned by the remote device since its last restart, clear counters operation, or power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnBusExceptionErrorCountResponse(data)

The response data field returns the quantity of modbus exception responses returned by the remote device since its last restart, clear counters operation, or power-up

class pymodbus.diag_message.ReturnSlaveMessageCountRequest(data=0)

The response data field returns the quantity of messages addressed to the remote device, or broadcast, that the remote device has processed since its last restart, clear counters operation, or power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnSlaveMessageCountResponse(data)

The response data field returns the quantity of messages addressed to the remote device, or broadcast, that the remote device has processed since its last restart, clear counters operation, or power-up

class pymodbus.diag_message.ReturnSlaveNoResponseCountRequest(data=0)

The response data field returns the quantity of messages addressed to the remote device, or broadcast, that the remote device has processed since its last restart, clear counters operation, or power-up

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnSlaveNoReponseCountResponse(data)

The response data field returns the quantity of messages addressed to the remote device, or broadcast, that the remote device has processed since its last restart, clear counters operation, or power-up

class pymodbus.diag_message.ReturnSlaveNAKCountRequest(data=0)

The response data field returns the quantity of messages addressed to the remote device for which it returned a Negative Acknowledge (NAK) exception response, since its last restart, clear counters operation, or power-up. Exception responses are described and listed in section 7 .

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnSlaveNAKCountResponse(data)

The response data field returns the quantity of messages addressed to the remote device for which it returned a Negative Acknowledge (NAK) exception response, since its last restart, clear counters operation, or power-up. Exception responses are described and listed in section 7.

class pymodbus.diag_message.ReturnSlaveBusyCountRequest(data=0)

The response data field returns the quantity of messages addressed to the remote device for which it returned a Slave Device Busy exception response, since its last restart, clear counters operation, or power-up.

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnSlaveBusyCountResponse(data)

The response data field returns the quantity of messages addressed to the remote device for which it returned a Slave Device Busy exception response, since its last restart, clear counters operation, or power-up.

class pymodbus.diag_message.ReturnSlaveBusCharacterOverrunCountRequest(data=0)

The response data field returns the quantity of messages addressed to the remote device that it could not handle due to a character overrun condition, since its last restart, clear counters operation, or power-up. A character overrun is caused by data characters arriving at the port faster than they can be stored, or by the loss of a character due to a hardware malfunction.

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ReturnSlaveBusCharacterOverrunCountResponse(data)

The response data field returns the quantity of messages addressed to the remote device that it could not handle due to a character overrun condition, since its last restart, clear counters operation, or power-up. A character overrun is caused by data characters arriving at the port faster than they can be stored, or by the loss of a character due to a hardware malfunction.

class pymodbus.diag_message.ClearOverrunCountRequest(data=0)

Clears the overrun error counter and reset the error flag

An error flag should be cleared, but nothing else in the specification mentions is, so it is ignored.

execute(*args)

Execute the diagnostic request on the given device

Returns:The initialized response message
class pymodbus.diag_message.ClearOverrunCountResponse(data)

Clears the overrun error counter and reset the error flag

Table Of Contents

Previous topic

datastore — Datastore for Modbus Server Context

Next topic

device — Modbus Device Representation

This Page