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)
-
enumerator NONE๏
๐จ 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.
-
enumerator NONE๏
๐ง 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.
-
enumerator RETURN_QUERY_DATA๏
๐ผ๏ธ 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.
-
enumerator NONE๏