Enumerations๏ƒ

This section documents all enumerations used in the libmodbus library.

๐ŸŽฎ Function Codes๏ƒ

ModbusFunctionCode๏ƒ

Defines all supported Modbus function codes.

enum class ModbusFunctionCode : uint8_t๏ƒ

Modbus function codes as defined in the Modbus specification.

This enumeration contains all the standard Modbus function codes supported by this library. Each function code corresponds to a specific operation that can be performed on Modbus data.

Values:

enumerator NONE๏ƒ

No function code (invalid/uninitialized)

enumerator READ_COILS๏ƒ

Read coils (discrete outputs) - FC 01.

enumerator READ_DISCRETE_INPUTS๏ƒ

Read discrete inputs - FC 02.

enumerator READ_HOLDING_REGISTERS๏ƒ

Read holding registers - FC 03.

enumerator READ_INPUT_REGISTERS๏ƒ

Read input registers - FC 04.

enumerator WRITE_SINGLE_COIL๏ƒ

Write single coil - FC 05.

enumerator WRITE_SINGLE_REGISTER๏ƒ

Write single register - FC 06.

enumerator READ_EXCEPTION_STATUS๏ƒ

Read exception status - FC 07.

enumerator DIAGNOSTICS๏ƒ

Diagnostics - FC 08.

enumerator WRITE_MULTIPLE_COILS๏ƒ

Write multiple coils - FC 15 (0x0F)

enumerator WRITE_MULTIPLE_REGISTERS๏ƒ

Write multiple registers - FC 16 (0x10)

๐Ÿšจ Exception Codes๏ƒ

ModbusExceptionCode๏ƒ

Defines all Modbus exception codes for error responses.

enum class ModbusExceptionCode : uint8_t๏ƒ

Modbus exception codes returned in error responses.

When a Modbus request cannot be processed successfully, the server responds with an exception frame containing one of these exception codes to indicate the specific error condition.

Values:

enumerator NONE๏ƒ

No exception (success)

enumerator ILLEGAL_FUNCTION๏ƒ

Function code not supported.

enumerator ILLEGAL_DATA_ADDRESS๏ƒ

Data address not valid.

enumerator ILLEGAL_DATA_VALUE๏ƒ

Data value not valid.

enumerator SLAVE_DEVICE_FAILURE๏ƒ

Unrecoverable error in slave device.

enumerator ACKNOWLEDGE๏ƒ

Request accepted, processing.

enumerator SLAVE_DEVICE_BUSY๏ƒ

Slave device busy.

enumerator NEGATIVE_ACKNOWLEDGMENT๏ƒ

Request cannot be performed.

enumerator MEMORY_PARITY_ERROR๏ƒ

Memory parity error.

enumerator GATEWAY_PATH_UNAVAILABLE๏ƒ

Gateway path unavailable.

enumerator GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND๏ƒ

Gateway target device failed to respond.

๐Ÿ”ง Diagnostic Codes๏ƒ

ModbusDiagnosticsCode๏ƒ

Defines sub-function codes for the Diagnostics function (FC 08).

enum class ModbusDiagnosticsCode : uint16_t๏ƒ

Diagnostic sub-function codes for function code 08 (Diagnostics)

The diagnostics function (FC 08) supports various sub-functions for testing communication and retrieving diagnostic information from Modbus devices. This enumeration defines the standard sub-function codes.

Values:

enumerator RETURN_QUERY_DATA๏ƒ

Echo back query data.

enumerator RESTART_COMMUNICATIONS_OPTION๏ƒ

Restart communications option.

enumerator RETURN_DIAGNOSTIC_REGISTER๏ƒ

Return diagnostic register.

enumerator CHANGE_ASCII_INPUT_DELIMITER๏ƒ

Change ASCII input delimiter.

enumerator FORCE_LISTEN_ONLY_MODE๏ƒ

Force listen only mode.

enumerator CLEAR_COUNTERS_AND_DIAGNOSTIC_REGISTER๏ƒ

Clear counters and diagnostic register.

enumerator RETURN_BUS_MESSAGE_COUNT๏ƒ

Return bus message count.

enumerator RETURN_BUS_COMMUNICATION_ERROR_COUNT๏ƒ

Return bus communication error count.

enumerator RETURN_BUS_EXCEPTION_ERROR_COUNT๏ƒ

Return bus exception error count.

enumerator RETURN_SLAVE_MESSAGE_COUNT๏ƒ

Return slave message count.

enumerator RETURN_SLAVE_NO_RESPONSE_COUNT๏ƒ

Return slave no response count.

enumerator RETURN_SLAVE_NAK_COUNT๏ƒ

Return slave NAK count.

enumerator RETURN_SLAVE_BUSY_COUNT๏ƒ

Return slave busy count.

enumerator RETURN_BUS_CHARACTER_OVERRUN_COUNT๏ƒ

Return bus character overrun count.

๐Ÿ–ผ๏ธ Frame Types๏ƒ

ModbusFrameType๏ƒ

Defines the type of Modbus frame being processed.

enum class ModbusFrameType๏ƒ

Enumeration of Modbus frame types.

This enumeration identifies the type of Modbus frame being processed, which determines how the frame should be interpreted and what response should be generated.

Values:

enumerator NONE๏ƒ

Uninitialized or invalid frame.

enumerator REQUEST๏ƒ

Request frame from client to server.

enumerator RESPONSE๏ƒ

Normal response frame from server to client.

enumerator EXCEPTION๏ƒ

Exception response frame indicating an error.