rodbus (C API) 1.3.1
Loading...
Searching...
No Matches
rodbus.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  rodbus_decode_level_t
 Controls the decoding of transmitted and received data at the application, frame, and physical layer. More...
 
struct  rodbus_bit_value_t
 Index/value tuple of a bit type. More...
 
struct  rodbus_register_value_t
 Index/value tuple of a register type. More...
 
struct  rodbus_runtime_config_t
 Runtime configuration. More...
 
struct  rodbus_address_range_t
 Range of 16-bit addresses sent in a request from the client to the server. More...
 
struct  rodbus_request_param_t
 Address and timeout parameters for requests. More...
 
struct  rodbus_serial_port_settings_t
 Serial port settings. More...
 
struct  rodbus_retry_strategy_t
 Retry strategy configuration. More...
 
struct  rodbus_logging_config_t
 Logging configuration options. More...
 
struct  rodbus_logger_t
 Logging interface that receives the log messages and writes them somewhere. More...
 
struct  rodbus_tls_client_config_t
 TLS client configuration. More...
 
struct  rodbus_client_state_listener_t
 Callback for monitoring the state of a TCP/TLS connection state. More...
 
struct  rodbus_port_state_listener_t
 Callback interface for receiving updates about the state of a serial port. More...
 
struct  rodbus_bit_read_callback_t
 Callbacks received when reading coils or discrete inputs. More...
 
struct  rodbus_register_read_callback_t
 Callbacks received when reading reading holding or input registers. More...
 
struct  rodbus_write_callback_t
 Callback methods received from asynchronous write operations. More...
 
struct  rodbus_database_callback_t
 Callback used to access the internal database while it is locked. More...
 
struct  rodbus_write_result_t
 Describes to the server if a write operation was successful or not. More...
 
struct  rodbus_write_handler_t
 Interface used to handle write requests received from the client. More...
 
struct  rodbus_tls_server_config_t
 TLS server configuration. More...
 
struct  rodbus_authorization_handler_t
 User implemented interface defines which request and roles are allowed for different functions when implementing Modbus security. More...
 

Macros

#define RODBUS_VERSION_MAJOR   1
 
#define RODBUS_VERSION_MINOR   3
 
#define RODBUS_VERSION_PATCH   1
 
#define RODBUS_VERSION_STRING   "1.3.1"
 

Typedefs

typedef struct rodbus_runtime_t rodbus_runtime_t
 Handle to the underlying runtime. More...
 
typedef struct rodbus_bit_value_iterator_t rodbus_bit_value_iterator_t
 Iterator of bit_value. More...
 
typedef struct rodbus_register_value_iterator_t rodbus_register_value_iterator_t
 Iterator of register_value. More...
 
typedef struct rodbus_client_channel_t rodbus_client_channel_t
 Abstract representation of a client communication channel. More...
 
typedef struct rodbus_bit_list_t rodbus_bit_list_t
 Collection of bit_list. More...
 
typedef struct rodbus_register_list_t rodbus_register_list_t
 Collection of register_list. More...
 
typedef struct rodbus_database_t rodbus_database_t
 Class used to add, remove, update, and retrieve values. More...
 
typedef struct rodbus_device_map_t rodbus_device_map_t
 Maps endpoint handlers to Modbus address. More...
 
typedef struct rodbus_address_filter_t rodbus_address_filter_t
 Filter used to restrict which IP addresses may communicate with a server. More...
 
typedef struct rodbus_server_t rodbus_server_t
 Handle to the running server. The server runs on a background task until this class is destroyed. More...
 

Enumerations

enum  rodbus_param_error_t {
  RODBUS_PARAM_ERROR_OK = 0 , RODBUS_PARAM_ERROR_NO_SUPPORT = 1 , RODBUS_PARAM_ERROR_NULL_PARAMETER = 2 , RODBUS_PARAM_ERROR_LOGGING_ALREADY_CONFIGURED = 3 ,
  RODBUS_PARAM_ERROR_RUNTIME_CREATION_FAILURE = 4 , RODBUS_PARAM_ERROR_RUNTIME_DESTROYED = 5 , RODBUS_PARAM_ERROR_RUNTIME_CANNOT_BLOCK_WITHIN_ASYNC = 6 , RODBUS_PARAM_ERROR_INVALID_IP_ADDRESS = 7 ,
  RODBUS_PARAM_ERROR_INVALID_RANGE = 8 , RODBUS_PARAM_ERROR_INVALID_REQUEST = 9 , RODBUS_PARAM_ERROR_INVALID_INDEX = 10 , RODBUS_PARAM_ERROR_SERVER_BIND_ERROR = 11 ,
  RODBUS_PARAM_ERROR_INVALID_UNIT_ID = 12 , RODBUS_PARAM_ERROR_INVALID_PEER_CERTIFICATE = 13 , RODBUS_PARAM_ERROR_INVALID_LOCAL_CERTIFICATE = 14 , RODBUS_PARAM_ERROR_INVALID_PRIVATE_KEY = 15 ,
  RODBUS_PARAM_ERROR_INVALID_DNS_NAME = 16 , RODBUS_PARAM_ERROR_BAD_TLS_CONFIG = 17 , RODBUS_PARAM_ERROR_SHUTDOWN = 18 , RODBUS_PARAM_ERROR_INVALID_UTF8 = 19
}
 Error type that indicates a bad parameter or bad programmer logic. More...
 
enum  rodbus_nothing_t { RODBUS_NOTHING_NOTHING = 0 }
 A single value enum which is used as a placeholder for futures that don't return a value. More...
 
enum  rodbus_app_decode_level_t { RODBUS_APP_DECODE_LEVEL_NOTHING = 0 , RODBUS_APP_DECODE_LEVEL_FUNCTION_CODE = 1 , RODBUS_APP_DECODE_LEVEL_DATA_HEADERS = 2 , RODBUS_APP_DECODE_LEVEL_DATA_VALUES = 3 }
 Controls how transmitted and received message at the application layer are decoded at the INFO log level. More...
 
enum  rodbus_frame_decode_level_t { RODBUS_FRAME_DECODE_LEVEL_NOTHING = 0 , RODBUS_FRAME_DECODE_LEVEL_HEADER = 1 , RODBUS_FRAME_DECODE_LEVEL_PAYLOAD = 2 }
 Controls how the transmitted and received frames are decoded at the INFO log level. More...
 
enum  rodbus_phys_decode_level_t { RODBUS_PHYS_DECODE_LEVEL_NOTHING = 0 , RODBUS_PHYS_DECODE_LEVEL_LENGTH = 1 , RODBUS_PHYS_DECODE_LEVEL_DATA = 2 }
 Controls how data transmitted at the physical layer (TCP, serial, etc) is logged. More...
 
enum  rodbus_request_error_t {
  RODBUS_REQUEST_ERROR_OK = 0 , RODBUS_REQUEST_ERROR_SHUTDOWN = 1 , RODBUS_REQUEST_ERROR_NO_CONNECTION = 2 , RODBUS_REQUEST_ERROR_RESPONSE_TIMEOUT = 3 ,
  RODBUS_REQUEST_ERROR_BAD_REQUEST = 4 , RODBUS_REQUEST_ERROR_BAD_RESPONSE = 5 , RODBUS_REQUEST_ERROR_IO_ERROR = 6 , RODBUS_REQUEST_ERROR_BAD_FRAMING = 7 ,
  RODBUS_REQUEST_ERROR_INTERNAL_ERROR = 8 , RODBUS_REQUEST_ERROR_BAD_ARGUMENT = 9 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 10 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS = 11 ,
  RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE = 12 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE = 13 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ACKNOWLEDGE = 14 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY = 15 ,
  RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR = 16 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE = 17 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = 18 , RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_UNKNOWN = 19
}
 Error information returned from asynchronous functions calls. More...
 
enum  rodbus_modbus_exception_t {
  RODBUS_MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 1 , RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS = 2 , RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE = 3 , RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE = 4 ,
  RODBUS_MODBUS_EXCEPTION_ACKNOWLEDGE = 5 , RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY = 6 , RODBUS_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR = 8 , RODBUS_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE = 10 ,
  RODBUS_MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = 11 , RODBUS_MODBUS_EXCEPTION_UNKNOWN = 255
}
 Error information returned during asynchronous API calls. More...
 
enum  rodbus_data_bits_t { RODBUS_DATA_BITS_FIVE = 0 , RODBUS_DATA_BITS_SIX = 1 , RODBUS_DATA_BITS_SEVEN = 2 , RODBUS_DATA_BITS_EIGHT = 3 }
 Number of bits per character. More...
 
enum  rodbus_flow_control_t { RODBUS_FLOW_CONTROL_NONE = 0 , RODBUS_FLOW_CONTROL_SOFTWARE = 1 , RODBUS_FLOW_CONTROL_HARDWARE = 2 }
 Flow control modes. More...
 
enum  rodbus_parity_t { RODBUS_PARITY_NONE = 0 , RODBUS_PARITY_ODD = 1 , RODBUS_PARITY_EVEN = 2 }
 Parity checking modes. More...
 
enum  rodbus_stop_bits_t { RODBUS_STOP_BITS_ONE = 0 , RODBUS_STOP_BITS_TWO = 1 }
 Number of stop bits. More...
 
enum  rodbus_min_tls_version_t { RODBUS_MIN_TLS_VERSION_V12 = 0 , RODBUS_MIN_TLS_VERSION_V13 = 1 }
 Minimum TLS version to allow. More...
 
enum  rodbus_certificate_mode_t { RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED = 0 , RODBUS_CERTIFICATE_MODE_SELF_SIGNED = 1 }
 Determines how the certificate(s) presented by the peer are validated. More...
 
enum  rodbus_log_level_t {
  RODBUS_LOG_LEVEL_ERROR = 0 , RODBUS_LOG_LEVEL_WARN = 1 , RODBUS_LOG_LEVEL_INFO = 2 , RODBUS_LOG_LEVEL_DEBUG = 3 ,
  RODBUS_LOG_LEVEL_TRACE = 4
}
 Log level. More...
 
enum  rodbus_log_output_format_t { RODBUS_LOG_OUTPUT_FORMAT_TEXT = 0 , RODBUS_LOG_OUTPUT_FORMAT_JSON = 1 }
 Describes how each log event is formatted. More...
 
enum  rodbus_time_format_t { RODBUS_TIME_FORMAT_NONE = 0 , RODBUS_TIME_FORMAT_RFC_3339 = 1 , RODBUS_TIME_FORMAT_SYSTEM = 2 }
 Describes if and how the time will be formatted in log messages. More...
 
enum  rodbus_client_state_t {
  RODBUS_CLIENT_STATE_DISABLED = 0 , RODBUS_CLIENT_STATE_CONNECTING = 1 , RODBUS_CLIENT_STATE_CONNECTED = 2 , RODBUS_CLIENT_STATE_WAIT_AFTER_FAILED_CONNECT = 3 ,
  RODBUS_CLIENT_STATE_WAIT_AFTER_DISCONNECT = 4 , RODBUS_CLIENT_STATE_SHUTDOWN = 5
}
 State of the client connection. More...
 
enum  rodbus_port_state_t { RODBUS_PORT_STATE_DISABLED = 0 , RODBUS_PORT_STATE_WAIT = 1 , RODBUS_PORT_STATE_OPEN = 2 , RODBUS_PORT_STATE_SHUTDOWN = 3 }
 State of the serial port. More...
 
enum  rodbus_authorization_t { RODBUS_AUTHORIZATION_ALLOW = 0 , RODBUS_AUTHORIZATION_DENY = 1 }
 Authorization result used by rodbus_authorization_handler_t. More...
 

Functions

static const char * rodbus_param_error_to_string (rodbus_param_error_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_nothing_to_string (rodbus_nothing_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_app_decode_level_to_string (rodbus_app_decode_level_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_frame_decode_level_to_string (rodbus_frame_decode_level_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_phys_decode_level_to_string (rodbus_phys_decode_level_t value)
 Converts the enum to a string. More...
 
static rodbus_decode_level_t rodbus_decode_level_build (rodbus_app_decode_level_t app, rodbus_frame_decode_level_t frame, rodbus_phys_decode_level_t physical)
 Fully construct rodbus_decode_level_t specifying the value of each field. More...
 
static rodbus_decode_level_t rodbus_decode_level_nothing ()
 Initialize log levels to defaults which is to decode nothing. More...
 
static rodbus_bit_value_t rodbus_bit_value_init (uint16_t index, bool value)
 Fully construct rodbus_bit_value_t specifying the value of each field. More...
 
static rodbus_register_value_t rodbus_register_value_init (uint16_t index, uint16_t value)
 Fully construct rodbus_register_value_t specifying the value of each field. More...
 
static rodbus_runtime_config_t rodbus_runtime_config_init ()
 Initialize the configuration to default values. More...
 
rodbus_param_error_t rodbus_runtime_create (rodbus_runtime_config_t config, rodbus_runtime_t **out)
 Creates a new runtime for running the protocol stack. More...
 
void rodbus_runtime_destroy (rodbus_runtime_t *instance)
 Destroy a runtime. More...
 
void rodbus_runtime_set_shutdown_timeout (rodbus_runtime_t *instance, uint64_t timeout)
 By default, when the runtime shuts down, it does so without a timeout and waits indefinitely for all spawned tasks to yield. More...
 
static const char * rodbus_request_error_to_string (rodbus_request_error_t value)
 Converts the enum to a string. More...
 
static rodbus_address_range_t rodbus_address_range_init (uint16_t start, uint16_t count)
 Fully construct rodbus_address_range_t specifying the value of each field. More...
 
static rodbus_request_param_t rodbus_request_param_init (uint8_t unit_id, uint64_t timeout)
 Fully construct rodbus_request_param_t specifying the value of each field. More...
 
rodbus_bit_value_trodbus_bit_value_iterator_next (rodbus_bit_value_iterator_t *iter)
 returns a pointer to the next value or NULL More...
 
rodbus_register_value_trodbus_register_value_iterator_next (rodbus_register_value_iterator_t *iter)
 returns a pointer to the next value or NULL More...
 
static const char * rodbus_modbus_exception_to_string (rodbus_modbus_exception_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_data_bits_to_string (rodbus_data_bits_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_flow_control_to_string (rodbus_flow_control_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_parity_to_string (rodbus_parity_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_stop_bits_to_string (rodbus_stop_bits_t value)
 Converts the enum to a string. More...
 
static rodbus_serial_port_settings_t rodbus_serial_port_settings_init ()
 Initialize a serial port configuration. More...
 
static const char * rodbus_min_tls_version_to_string (rodbus_min_tls_version_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_certificate_mode_to_string (rodbus_certificate_mode_t value)
 Converts the enum to a string. More...
 
static rodbus_retry_strategy_t rodbus_retry_strategy_init ()
 Initialize a retry strategy to defaults. More...
 
static const char * rodbus_log_level_to_string (rodbus_log_level_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_log_output_format_to_string (rodbus_log_output_format_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_time_format_to_string (rodbus_time_format_t value)
 Converts the enum to a string. More...
 
static rodbus_logging_config_t rodbus_logging_config_init ()
 Initialize the configuration to default values. More...
 
rodbus_param_error_t rodbus_configure_logging (rodbus_logging_config_t config, rodbus_logger_t logger)
 Set the callback that will receive all the log messages. More...
 
static rodbus_tls_client_config_t rodbus_tls_client_config_init (const char *dns_name, const char *peer_cert_path, const char *local_cert_path, const char *private_key_path, const char *password)
 Initialize a TLS client configuration. More...
 
static const char * rodbus_client_state_to_string (rodbus_client_state_t value)
 Converts the enum to a string. More...
 
static const char * rodbus_port_state_to_string (rodbus_port_state_t value)
 Converts the enum to a string. More...
 
rodbus_param_error_t rodbus_client_channel_create_tcp (rodbus_runtime_t *runtime, const char *host, uint16_t port, uint16_t max_queued_requests, rodbus_retry_strategy_t retry_strategy, rodbus_decode_level_t decode_level, rodbus_client_state_listener_t listener, rodbus_client_channel_t **out)
 Create a new TCP channel instance. More...
 
rodbus_param_error_t rodbus_client_channel_create_rtu (rodbus_runtime_t *runtime, const char *path, rodbus_serial_port_settings_t serial_params, uint16_t max_queued_requests, rodbus_retry_strategy_t retry_strategy, rodbus_decode_level_t decode_level, rodbus_port_state_listener_t listener, rodbus_client_channel_t **out)
 Create a new RTU channel instance. More...
 
rodbus_param_error_t rodbus_client_channel_create_tls (rodbus_runtime_t *runtime, const char *host, uint16_t port, uint16_t max_queued_requests, rodbus_retry_strategy_t retry_strategy, rodbus_tls_client_config_t tls_config, rodbus_decode_level_t decode_level, rodbus_client_state_listener_t listener, rodbus_client_channel_t **out)
 Create a new TLS channel instance. More...
 
void rodbus_client_channel_destroy (rodbus_client_channel_t *instance)
 Shutdown a rodbus_client_channel_t and release all resources. More...
 
rodbus_param_error_t rodbus_client_channel_read_coils (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_address_range_t range, rodbus_bit_read_callback_t callback)
 Start an asynchronous request to read coils. More...
 
rodbus_param_error_t rodbus_client_channel_read_discrete_inputs (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_address_range_t range, rodbus_bit_read_callback_t callback)
 Start an asynchronous request to read discrete inputs. More...
 
rodbus_param_error_t rodbus_client_channel_read_holding_registers (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_address_range_t range, rodbus_register_read_callback_t callback)
 Start an asynchronous request to read holding registers. More...
 
rodbus_param_error_t rodbus_client_channel_read_input_registers (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_address_range_t range, rodbus_register_read_callback_t callback)
 Start an asynchronous request to read input registers. More...
 
rodbus_param_error_t rodbus_client_channel_write_single_coil (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_bit_value_t value, rodbus_write_callback_t callback)
 Write a single coil. More...
 
rodbus_param_error_t rodbus_client_channel_write_single_register (rodbus_client_channel_t *instance, rodbus_request_param_t param, rodbus_register_value_t value, rodbus_write_callback_t callback)
 Write a single register. More...
 
rodbus_bit_list_trodbus_bit_list_create (uint32_t reserve_size)
 Creates an instance of the collection. More...
 
void rodbus_bit_list_destroy (rodbus_bit_list_t *instance)
 Destroys an instance of the collection. More...
 
void rodbus_bit_list_add (rodbus_bit_list_t *instance, bool value)
 Add a value to the collection. More...
 
rodbus_param_error_t rodbus_client_channel_write_multiple_coils (rodbus_client_channel_t *instance, rodbus_request_param_t param, uint16_t start, rodbus_bit_list_t *items, rodbus_write_callback_t callback)
 Write multiple coils. More...
 
rodbus_register_list_trodbus_register_list_create (uint32_t reserve_size)
 Creates an instance of the collection. More...
 
void rodbus_register_list_destroy (rodbus_register_list_t *instance)
 Destroys an instance of the collection. More...
 
void rodbus_register_list_add (rodbus_register_list_t *instance, uint16_t value)
 Add a value to the collection. More...
 
rodbus_param_error_t rodbus_client_channel_write_multiple_registers (rodbus_client_channel_t *instance, rodbus_request_param_t param, uint16_t start, rodbus_register_list_t *items, rodbus_write_callback_t callback)
 Write multiple registers. More...
 
rodbus_param_error_t rodbus_client_channel_set_decode_level (rodbus_client_channel_t *instance, rodbus_decode_level_t level)
 Set the decoding level for the channel. More...
 
rodbus_param_error_t rodbus_client_channel_enable (rodbus_client_channel_t *instance)
 Enable channel communications. More...
 
rodbus_param_error_t rodbus_client_channel_disable (rodbus_client_channel_t *instance)
 Disable channel communications. More...
 
bool rodbus_database_add_coil (rodbus_database_t *instance, uint16_t index, bool value)
 Add a new coil to the database. More...
 
bool rodbus_database_add_discrete_input (rodbus_database_t *instance, uint16_t index, bool value)
 Add a new discrete input to the database. More...
 
bool rodbus_database_add_holding_register (rodbus_database_t *instance, uint16_t index, uint16_t value)
 Add a new holding register to the database. More...
 
bool rodbus_database_add_input_register (rodbus_database_t *instance, uint16_t index, uint16_t value)
 Add a new input register to the database. More...
 
rodbus_param_error_t rodbus_database_get_coil (rodbus_database_t *instance, uint16_t index, bool *out)
 Get the current coil value of the database. More...
 
rodbus_param_error_t rodbus_database_get_discrete_input (rodbus_database_t *instance, uint16_t index, bool *out)
 Get the current discrete input value of the database. More...
 
rodbus_param_error_t rodbus_database_get_holding_register (rodbus_database_t *instance, uint16_t index, uint16_t *out)
 Get the current holding register value of the database. More...
 
rodbus_param_error_t rodbus_database_get_input_register (rodbus_database_t *instance, uint16_t index, uint16_t *out)
 Get the current input register value of the database. More...
 
bool rodbus_database_update_coil (rodbus_database_t *instance, uint16_t index, bool value)
 Update the current value of a coil in the database. More...
 
bool rodbus_database_update_discrete_input (rodbus_database_t *instance, uint16_t index, bool value)
 Update the current value of a discrete input in the database. More...
 
bool rodbus_database_update_holding_register (rodbus_database_t *instance, uint16_t index, uint16_t value)
 Update the current value of a holding register in the database. More...
 
bool rodbus_database_update_input_register (rodbus_database_t *instance, uint16_t index, uint16_t value)
 Update the current value of a input register in the database. More...
 
bool rodbus_database_delete_coil (rodbus_database_t *instance, uint16_t index)
 Remove a coil address from the database. More...
 
bool rodbus_database_delete_discrete_input (rodbus_database_t *instance, uint16_t index)
 Remove a discrete input address from the database. More...
 
bool rodbus_database_delete_holding_register (rodbus_database_t *instance, uint16_t index)
 Remove a holding register address from the database. More...
 
bool rodbus_database_delete_input_register (rodbus_database_t *instance, uint16_t index)
 Remove a input register address from the database. More...
 
static rodbus_write_result_t rodbus_write_result_success_init ()
 Initialize a rodbus_write_result_t to indicate a successful write operation. More...
 
static rodbus_write_result_t rodbus_write_result_exception_init (rodbus_modbus_exception_t exception)
 Initialize a rodbus_write_result_t to indicate a standard Modbus exception. More...
 
static rodbus_write_result_t rodbus_write_result_raw_exception_init (uint8_t raw_exception)
 Initialize a rodbus_write_result_t to indicate a non-standard Modbus exception. More...
 
rodbus_device_map_trodbus_device_map_create ()
 Create a device map that will be used to bind devices to a server endpoint. More...
 
void rodbus_device_map_destroy (rodbus_device_map_t *instance)
 Destroy a previously created device map. More...
 
bool rodbus_device_map_add_endpoint (rodbus_device_map_t *instance, uint8_t unit_id, rodbus_write_handler_t handler, rodbus_database_callback_t configure)
 Add an endpoint to the map. More...
 
static rodbus_tls_server_config_t rodbus_tls_server_config_init (const char *peer_cert_path, const char *local_cert_path, const char *private_key_path, const char *password)
 Initialize a TLS client configuration. More...
 
static const char * rodbus_authorization_to_string (rodbus_authorization_t value)
 Converts the enum to a string. More...
 
rodbus_address_filter_trodbus_address_filter_any ()
 Create an address filter that accepts any IP address. More...
 
rodbus_param_error_t rodbus_address_filter_create (const char *address, rodbus_address_filter_t **out)
 Create an address filter that matches one or more IP addresses. Ipv4 or IPv6 addresses are allowed. More...
 
rodbus_param_error_t rodbus_address_filter_add (rodbus_address_filter_t *instance, const char *address)
 Add an allowed IP address to the filter. More...
 
void rodbus_address_filter_destroy (rodbus_address_filter_t *instance)
 Destroy an address filter. More...
 
rodbus_param_error_t rodbus_server_create_tcp (rodbus_runtime_t *runtime, const char *address, uint16_t port, rodbus_address_filter_t *filter, uint16_t max_sessions, rodbus_device_map_t *endpoints, rodbus_decode_level_t decode_level, rodbus_server_t **out)
 Launch a TCP server. More...
 
rodbus_param_error_t rodbus_server_create_rtu (rodbus_runtime_t *runtime, const char *path, rodbus_serial_port_settings_t serial_params, rodbus_retry_strategy_t retry, rodbus_device_map_t *endpoints, rodbus_decode_level_t decode_level, rodbus_server_t **out)
 Launch a RTU server. More...
 
rodbus_param_error_t rodbus_server_create_tls_with_authz (rodbus_runtime_t *runtime, const char *address, uint16_t port, rodbus_address_filter_t *filter, uint16_t max_sessions, rodbus_device_map_t *endpoints, rodbus_tls_server_config_t tls_config, rodbus_authorization_handler_t authorization_handler, rodbus_decode_level_t decode_level, rodbus_server_t **out)
 Create a Modbus Security (TLS) server. More...
 
rodbus_param_error_t rodbus_server_create_tls (rodbus_runtime_t *runtime, const char *address, uint16_t port, rodbus_address_filter_t *filter, uint16_t max_sessions, rodbus_device_map_t *endpoints, rodbus_tls_server_config_t tls_config, rodbus_decode_level_t decode_level, rodbus_server_t **out)
 Create a TLS server that does NOT require the client role extension. More...
 
void rodbus_server_destroy (rodbus_server_t *instance)
 Shutdown and release all resources of a running server. More...
 
rodbus_param_error_t rodbus_server_update_database (rodbus_server_t *instance, uint8_t unit_id, rodbus_database_callback_t transaction)
 Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction. More...
 
rodbus_param_error_t rodbus_server_set_decode_level (rodbus_server_t *instance, rodbus_decode_level_t level)
 Set the decoding level for the server. More...
 
const char * rodbus_version ()
 Get the version of the library as a string. More...
 

Detailed Description

C API for the rodbus library

Typedef Documentation

◆ rodbus_address_filter_t

Filter used to restrict which IP addresses may communicate with a server.

◆ rodbus_bit_list_t

Collection of bit_list.

◆ rodbus_bit_value_iterator_t

Iterator of bit_value.

◆ rodbus_client_channel_t

Abstract representation of a client communication channel.

The underlying channel may be TCP, TLS, or serial.

◆ rodbus_database_t

Class used to add, remove, update, and retrieve values.

◆ rodbus_device_map_t

Maps endpoint handlers to Modbus address.

◆ rodbus_register_list_t

Collection of register_list.

◆ rodbus_register_value_iterator_t

Iterator of register_value.

◆ rodbus_runtime_t

Handle to the underlying runtime.

◆ rodbus_server_t

Handle to the running server. The server runs on a background task until this class is destroyed.

Enumeration Type Documentation

◆ rodbus_app_decode_level_t

Controls how transmitted and received message at the application layer are decoded at the INFO log level.

Application-layer messages are referred to as Protocol Data Units (PDUs) in the specification.

Enumerator
RODBUS_APP_DECODE_LEVEL_NOTHING 

Decode nothing.

RODBUS_APP_DECODE_LEVEL_FUNCTION_CODE 

Decode the function code only.

RODBUS_APP_DECODE_LEVEL_DATA_HEADERS 

Decode the function code and the general description of the data.

RODBUS_APP_DECODE_LEVEL_DATA_VALUES 

Decode the function code, the general description of the data and the actual data values.

◆ rodbus_authorization_t

Authorization result used by rodbus_authorization_handler_t.

Enumerator
RODBUS_AUTHORIZATION_ALLOW 

Client is authorized to perform the operation.

RODBUS_AUTHORIZATION_DENY 

Client is NOT authorized to perform the operation.

◆ rodbus_certificate_mode_t

Determines how the certificate(s) presented by the peer are validated.

This validation always occurs after the handshake signature has been verified.

Enumerator
RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED 

Validates the peer certificate against one or more configured trust anchors.

This mode uses the default certificate verifier in `rustls` to ensure that the chain of certificates presented by the peer is valid against one of the configured trust anchors.

The name verification is relaxed to allow for certificates that do not contain the SAN extension. In these cases the name is verified using the Common Name instead. 
RODBUS_CERTIFICATE_MODE_SELF_SIGNED 

Validates that the peer presents a single certificate which is a byte-for-byte match against the configured peer certificate.

The certificate is parsed only to ensure that the `NotBefore` and `NotAfter` are valid for the current system time. 

◆ rodbus_client_state_t

State of the client connection.

Used by the rodbus_client_state_listener_t.

Enumerator
RODBUS_CLIENT_STATE_DISABLED 

Client is disabled and idle until enabled.

RODBUS_CLIENT_STATE_CONNECTING 

Client is trying to establish a connection to the remote device.

RODBUS_CLIENT_STATE_CONNECTED 

Client is connected to the remote device.

RODBUS_CLIENT_STATE_WAIT_AFTER_FAILED_CONNECT 

Failed to establish a connection, waiting before retrying.

RODBUS_CLIENT_STATE_WAIT_AFTER_DISCONNECT 

Client was disconnected, waiting before retrying.

RODBUS_CLIENT_STATE_SHUTDOWN 

Client is shutting down.

◆ rodbus_data_bits_t

Number of bits per character.

Enumerator
RODBUS_DATA_BITS_FIVE 

5 bits per character

RODBUS_DATA_BITS_SIX 

6 bits per character

RODBUS_DATA_BITS_SEVEN 

7 bits per character

RODBUS_DATA_BITS_EIGHT 

8 bits per character

◆ rodbus_flow_control_t

Flow control modes.

Enumerator
RODBUS_FLOW_CONTROL_NONE 

No flow control.

RODBUS_FLOW_CONTROL_SOFTWARE 

Flow control using XON/XOFF bytes.

RODBUS_FLOW_CONTROL_HARDWARE 

Flow control using RTS/CTS signals.

◆ rodbus_frame_decode_level_t

Controls how the transmitted and received frames are decoded at the INFO log level.

Transport-specific framing wraps the application-layer traffic. You'll see these frames called ADUs in the Modbus specification.

On TCP, this is the MBAP decoding. On serial, this controls the serial line PDU.

Enumerator
RODBUS_FRAME_DECODE_LEVEL_NOTHING 

Log nothing.

RODBUS_FRAME_DECODE_LEVEL_HEADER 

Decode the header.

RODBUS_FRAME_DECODE_LEVEL_PAYLOAD 

Decode the header and the raw payload as hexadecimal.

◆ rodbus_log_level_t

Log level.

Used in rodbus_logger_t::on_message callback to identify the log level of a message.

Enumerator
RODBUS_LOG_LEVEL_ERROR 

Error log level.

RODBUS_LOG_LEVEL_WARN 

Warning log level.

RODBUS_LOG_LEVEL_INFO 

Information log level.

RODBUS_LOG_LEVEL_DEBUG 

Debugging log level.

RODBUS_LOG_LEVEL_TRACE 

Trace log level.

◆ rodbus_log_output_format_t

Describes how each log event is formatted.

Enumerator
RODBUS_LOG_OUTPUT_FORMAT_TEXT 

A simple text-based format.

RODBUS_LOG_OUTPUT_FORMAT_JSON 

Output formatted as JSON.

◆ rodbus_min_tls_version_t

Minimum TLS version to allow.

Enumerator
RODBUS_MIN_TLS_VERSION_V12 

TLS 1.2.

RODBUS_MIN_TLS_VERSION_V13 

TLS 1.3.

◆ rodbus_modbus_exception_t

Error information returned during asynchronous API calls.

Enumerator
RODBUS_MODBUS_EXCEPTION_ILLEGAL_FUNCTION 

The data address received in the query is not an allowable address for the server.

RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS 

The data address received in the query is not an allowable address for the server.

RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE 

A value contained in the request is not an allowable value for server.

RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE 

An unrecoverable error occurred while the server was attempting to perform the requested action.

RODBUS_MODBUS_EXCEPTION_ACKNOWLEDGE 

Specialized use in conjunction with programming commands. The server has accepted the request and is processing it.

RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY 

Specialized use in conjunction with programming commands. The server is engaged in processing a long-duration program command, try again later.

RODBUS_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR 

Specialized use in conjunction with function codes 20 and 21 and reference type 6, to indicate that the extended file area failed to pass a consistency check. The server attempted to read a record file, but detected a parity error in the memory.

RODBUS_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE 

Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an internal communication path from the input port to the output port for processing the request. Usually means that the gateway is mis-configured or overloaded.

RODBUS_MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND 

Specialized use in conjunction with gateways, indicates that no response was obtained from the target device. Usually means that the device is not present on the network.

RODBUS_MODBUS_EXCEPTION_UNKNOWN 

The status code is not defined in the Modbus specification, refer to the raw exception code to see what the server sent.

◆ rodbus_nothing_t

A single value enum which is used as a placeholder for futures that don't return a value.

Enumerator
RODBUS_NOTHING_NOTHING 

the only value this enum has

◆ rodbus_param_error_t

Error type that indicates a bad parameter or bad programmer logic.

Enumerator
RODBUS_PARAM_ERROR_OK 

Success, i.e. no error occurred.

RODBUS_PARAM_ERROR_NO_SUPPORT 

The FFI library was compiled without support for this feature.

RODBUS_PARAM_ERROR_NULL_PARAMETER 

Null parameter.

RODBUS_PARAM_ERROR_LOGGING_ALREADY_CONFIGURED 

Logging can only be configured once.

RODBUS_PARAM_ERROR_RUNTIME_CREATION_FAILURE 

Failed to create Tokio runtime.

RODBUS_PARAM_ERROR_RUNTIME_DESTROYED 

Runtime was already disposed of.

RODBUS_PARAM_ERROR_RUNTIME_CANNOT_BLOCK_WITHIN_ASYNC 

Runtime cannot execute blocking call within asynchronous context.

RODBUS_PARAM_ERROR_INVALID_IP_ADDRESS 

Invalid IP address.

RODBUS_PARAM_ERROR_INVALID_RANGE 

Invalid Modbus address range.

RODBUS_PARAM_ERROR_INVALID_REQUEST 

Invalid Modbus request.

RODBUS_PARAM_ERROR_INVALID_INDEX 

Invalid index.

RODBUS_PARAM_ERROR_SERVER_BIND_ERROR 

Server failed to bind to the specified port.

RODBUS_PARAM_ERROR_INVALID_UNIT_ID 

The specified unit id is not associated to this server.

RODBUS_PARAM_ERROR_INVALID_PEER_CERTIFICATE 

Invalid peer certificate file.

RODBUS_PARAM_ERROR_INVALID_LOCAL_CERTIFICATE 

Invalid local certificate file.

RODBUS_PARAM_ERROR_INVALID_PRIVATE_KEY 

Invalid private key file.

RODBUS_PARAM_ERROR_INVALID_DNS_NAME 

Invalid DNS name.

RODBUS_PARAM_ERROR_BAD_TLS_CONFIG 

Bad TLS configuration.

RODBUS_PARAM_ERROR_SHUTDOWN 

The task has been shutdown.

RODBUS_PARAM_ERROR_INVALID_UTF8 

String argument was not valid UTF-8.

◆ rodbus_parity_t

Parity checking modes.

Enumerator
RODBUS_PARITY_NONE 

No parity bit.

RODBUS_PARITY_ODD 

Parity bit sets odd number of 1 bits.

RODBUS_PARITY_EVEN 

Parity bit sets even number of 1 bits.

◆ rodbus_phys_decode_level_t

Controls how data transmitted at the physical layer (TCP, serial, etc) is logged.

Enumerator
RODBUS_PHYS_DECODE_LEVEL_NOTHING 

Log nothing.

RODBUS_PHYS_DECODE_LEVEL_LENGTH 

Log only the length of data that is sent and received.

RODBUS_PHYS_DECODE_LEVEL_DATA 

Log the length and the actual data that is sent and received.

◆ rodbus_port_state_t

State of the serial port.

Used by the rodbus_port_state_listener_t.

Enumerator
RODBUS_PORT_STATE_DISABLED 

Disabled until enabled.

RODBUS_PORT_STATE_WAIT 

Waiting to perform an open retry.

RODBUS_PORT_STATE_OPEN 

Port is open.

RODBUS_PORT_STATE_SHUTDOWN 

Task has been shut down.

◆ rodbus_request_error_t

Error information returned from asynchronous functions calls.

Unlike rodbus_param_error_t, the values here generally represent spontaneous failures that are outside developer control, e.g. network failures, etc

Enumerator
RODBUS_REQUEST_ERROR_OK 

Success, i.e. no error occurred.

RODBUS_REQUEST_ERROR_SHUTDOWN 

The channel was shutdown before the operation could complete.

RODBUS_REQUEST_ERROR_NO_CONNECTION 

No connection could be made to the server.

RODBUS_REQUEST_ERROR_RESPONSE_TIMEOUT 

No valid response was received before the timeout.

RODBUS_REQUEST_ERROR_BAD_REQUEST 

The request was invalid.

RODBUS_REQUEST_ERROR_BAD_RESPONSE 

The response from the server was received but was improperly formatted.

RODBUS_REQUEST_ERROR_IO_ERROR 

An I/O error occurred on the underlying stream while performing the request.

RODBUS_REQUEST_ERROR_BAD_FRAMING 

A framing error was detected while performing the request.

RODBUS_REQUEST_ERROR_INTERNAL_ERROR 

An unspecified internal error occurred while performing the request.

RODBUS_REQUEST_ERROR_BAD_ARGUMENT 

An invalid argument was supplied and the request could not be performed.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_FUNCTION 

The data address received in the query is not an allowable address for the server.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS 

The data address received in the query is not an allowable address for the server.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE 

A value contained in the request is not an allowable value for server.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE 

An unrecoverable error occurred while the server was attempting to perform the requested action.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ACKNOWLEDGE 

Specialized use in conjunction with programming commands. The server has accepted the request and is processing it.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY 

Specialized use in conjunction with programming commands. The server is engaged in processing a long-duration program command, try again later.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR 

Specialized use in conjunction with function codes 20 and 21 and reference type 6, to indicate that the extended file area failed to pass a consistency check. The server attempted to read a record file, but detected a parity error in the memory.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE 

Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an internal communication path from the input port to the output port for processing the request. Usually means that the gateway is mis-configured or overloaded.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND 

Specialized use in conjunction with gateways, indicates that no response was obtained from the target device. Usually means that the device is not present on the network.

RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_UNKNOWN 

The status code is not defined in the Modbus specification, refer to the raw exception code to see what the server sent.

◆ rodbus_stop_bits_t

Number of stop bits.

Enumerator
RODBUS_STOP_BITS_ONE 

One stop bit.

RODBUS_STOP_BITS_TWO 

Two stop bits.

◆ rodbus_time_format_t

Describes if and how the time will be formatted in log messages.

Enumerator
RODBUS_TIME_FORMAT_NONE 

Don't format the timestamp as part of the message.

RODBUS_TIME_FORMAT_RFC_3339 

Format the time using RFC 3339.

RODBUS_TIME_FORMAT_SYSTEM 

Format the time in a human readable format e.g. 'Jun 25 14:27:12.955'.

Function Documentation

◆ rodbus_address_filter_add()

rodbus_param_error_t rodbus_address_filter_add ( rodbus_address_filter_t instance,
const char *  address 
)

Add an allowed IP address to the filter.

This function may only be called if the AddressFilter was initially constructed with a single static address

Parameters
instanceInstance of rodbus_address_filter_t
addressIP address to add
Returns
Error code

◆ rodbus_address_filter_any()

rodbus_address_filter_t * rodbus_address_filter_any ( )

Create an address filter that accepts any IP address.

Returns
Address filter

◆ rodbus_address_filter_create()

rodbus_param_error_t rodbus_address_filter_create ( const char *  address,
rodbus_address_filter_t **  out 
)

Create an address filter that matches one or more IP addresses. Ipv4 or IPv6 addresses are allowed.

Examples: 192.168.1.26, 192.168.0.*, *.*.*.*

Wildcards are only supported for IPv4 addresses

Parameters
addressIP address to accept
outInstance of rodbus_address_filter_t
Returns
Error code

◆ rodbus_address_filter_destroy()

void rodbus_address_filter_destroy ( rodbus_address_filter_t instance)

Destroy an address filter.

Parameters
instanceInstance of rodbus_address_filter_t to destroy

◆ rodbus_address_range_init()

static rodbus_address_range_t rodbus_address_range_init ( uint16_t  start,
uint16_t  count 
)
static

Fully construct rodbus_address_range_t specifying the value of each field.

Parameters
startStarting address of the range
countNumber of addresses in the range
Returns
New instance of rodbus_address_range_t

◆ rodbus_app_decode_level_to_string()

static const char * rodbus_app_decode_level_to_string ( rodbus_app_decode_level_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_authorization_to_string()

static const char * rodbus_authorization_to_string ( rodbus_authorization_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_bit_list_add()

void rodbus_bit_list_add ( rodbus_bit_list_t instance,
bool  value 
)

Add a value to the collection.

Parameters
instanceinstance to which to add the value
valuevalue to add to the instance

◆ rodbus_bit_list_create()

rodbus_bit_list_t * rodbus_bit_list_create ( uint32_t  reserve_size)

Creates an instance of the collection.

Parameters
reserve_sizepreallocate a particular size
Returns
Allocated opaque collection instance

◆ rodbus_bit_list_destroy()

void rodbus_bit_list_destroy ( rodbus_bit_list_t instance)

Destroys an instance of the collection.

Parameters
instanceinstance to destroy

◆ rodbus_bit_value_init()

static rodbus_bit_value_t rodbus_bit_value_init ( uint16_t  index,
bool  value 
)
static

Fully construct rodbus_bit_value_t specifying the value of each field.

Parameters
indexIndex of bit
valueValue of the bit
Returns
New instance of rodbus_bit_value_t

◆ rodbus_bit_value_iterator_next()

rodbus_bit_value_t * rodbus_bit_value_iterator_next ( rodbus_bit_value_iterator_t iter)

returns a pointer to the next value or NULL

Parameters
iteropaque iterator on which to retrieve the next value
Returns
next value or NULL

◆ rodbus_certificate_mode_to_string()

static const char * rodbus_certificate_mode_to_string ( rodbus_certificate_mode_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_client_channel_create_rtu()

rodbus_param_error_t rodbus_client_channel_create_rtu ( rodbus_runtime_t runtime,
const char *  path,
rodbus_serial_port_settings_t  serial_params,
uint16_t  max_queued_requests,
rodbus_retry_strategy_t  retry_strategy,
rodbus_decode_level_t  decode_level,
rodbus_port_state_listener_t  listener,
rodbus_client_channel_t **  out 
)

Create a new RTU channel instance.

Parameters
runtimeruntime on which to create the channel
pathPath to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows.
serial_paramsSerial port settings
max_queued_requestsMaximum number of requests to queue before failing the next request
retry_strategyStrategy which controls how long to wait between attempts to open the serial port after failures
decode_levelDecode levels for this client
listenerListener used to receive updates on the status of the serial port
outPointer to the created channel
Returns
Error code

◆ rodbus_client_channel_create_tcp()

rodbus_param_error_t rodbus_client_channel_create_tcp ( rodbus_runtime_t runtime,
const char *  host,
uint16_t  port,
uint16_t  max_queued_requests,
rodbus_retry_strategy_t  retry_strategy,
rodbus_decode_level_t  decode_level,
rodbus_client_state_listener_t  listener,
rodbus_client_channel_t **  out 
)

Create a new TCP channel instance.

Parameters
runtimeRuntime on which to create the channel
hostIP (v4/v6) or host name remote endpoint
portremote port
max_queued_requestsMaximum number of requests to queue before failing the next request
retry_strategyReconnection timing strategy
decode_levelDecode levels for this client
listenerTCP connection listener used to receive updates on the status of the channel
outPointer to the created channel
Returns
Error code

◆ rodbus_client_channel_create_tls()

rodbus_param_error_t rodbus_client_channel_create_tls ( rodbus_runtime_t runtime,
const char *  host,
uint16_t  port,
uint16_t  max_queued_requests,
rodbus_retry_strategy_t  retry_strategy,
rodbus_tls_client_config_t  tls_config,
rodbus_decode_level_t  decode_level,
rodbus_client_state_listener_t  listener,
rodbus_client_channel_t **  out 
)

Create a new TLS channel instance.

Parameters
runtimeRuntime on which to create the channel
hostIP (v4/v6) or host name remote endpoint
portremote port
max_queued_requestsMaximum number of requests to queue before failing the next request
retry_strategyReconnection timing strategy
tls_configTLS client configuration
decode_levelDecode levels for this client
listenerTCP connection listener used to receive updates on the status of the channel
outPointer to the created channel or NULL if an error occurred
Returns
Error code

◆ rodbus_client_channel_destroy()

void rodbus_client_channel_destroy ( rodbus_client_channel_t instance)

Shutdown a rodbus_client_channel_t and release all resources.

Parameters
instanceInstance of rodbus_client_channel_t to destroy

◆ rodbus_client_channel_disable()

rodbus_param_error_t rodbus_client_channel_disable ( rodbus_client_channel_t instance)

Disable channel communications.

Warning
May not be called from within the context of the runtime
Parameters
instanceInstance of rodbus_client_channel_t
Returns
Error code

◆ rodbus_client_channel_enable()

rodbus_param_error_t rodbus_client_channel_enable ( rodbus_client_channel_t instance)

Enable channel communications.

Warning
May not be called from within the context of the runtime
Parameters
instanceInstance of rodbus_client_channel_t
Returns
Error code

◆ rodbus_client_channel_read_coils()

rodbus_param_error_t rodbus_client_channel_read_coils ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_address_range_t  range,
rodbus_bit_read_callback_t  callback 
)

Start an asynchronous request to read coils.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
rangeRange of addresses to read
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_read_discrete_inputs()

rodbus_param_error_t rodbus_client_channel_read_discrete_inputs ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_address_range_t  range,
rodbus_bit_read_callback_t  callback 
)

Start an asynchronous request to read discrete inputs.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
rangeRange of addresses to read
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_read_holding_registers()

rodbus_param_error_t rodbus_client_channel_read_holding_registers ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_address_range_t  range,
rodbus_register_read_callback_t  callback 
)

Start an asynchronous request to read holding registers.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
rangeRange of addresses to read
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_read_input_registers()

rodbus_param_error_t rodbus_client_channel_read_input_registers ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_address_range_t  range,
rodbus_register_read_callback_t  callback 
)

Start an asynchronous request to read input registers.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
rangeRange of addresses to read
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_set_decode_level()

rodbus_param_error_t rodbus_client_channel_set_decode_level ( rodbus_client_channel_t instance,
rodbus_decode_level_t  level 
)

Set the decoding level for the channel.

Parameters
instanceInstance of rodbus_client_channel_t
levelDecoding level
Returns
Error code

◆ rodbus_client_channel_write_multiple_coils()

rodbus_param_error_t rodbus_client_channel_write_multiple_coils ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
uint16_t  start,
rodbus_bit_list_t items,
rodbus_write_callback_t  callback 
)

Write multiple coils.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
startStarting address
itemsList of items to write
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_write_multiple_registers()

rodbus_param_error_t rodbus_client_channel_write_multiple_registers ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
uint16_t  start,
rodbus_register_list_t items,
rodbus_write_callback_t  callback 
)

Write multiple registers.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
startStarting address
itemsList of items to write
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_write_single_coil()

rodbus_param_error_t rodbus_client_channel_write_single_coil ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_bit_value_t  value,
rodbus_write_callback_t  callback 
)

Write a single coil.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
valueAddress and value to write
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_channel_write_single_register()

rodbus_param_error_t rodbus_client_channel_write_single_register ( rodbus_client_channel_t instance,
rodbus_request_param_t  param,
rodbus_register_value_t  value,
rodbus_write_callback_t  callback 
)

Write a single register.

Parameters
instanceInstance of rodbus_client_channel_t
paramParameters for the request
valueAddress and value to write
callbackcallback invoked when the operation completes
Returns
Error code

◆ rodbus_client_state_to_string()

static const char * rodbus_client_state_to_string ( rodbus_client_state_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_configure_logging()

rodbus_param_error_t rodbus_configure_logging ( rodbus_logging_config_t  config,
rodbus_logger_t  logger 
)

Set the callback that will receive all the log messages.

There is only a single globally allocated logger. Calling this method a second time will return an error.

If this method is never called, no logging will be performed.

Parameters
configConfiguration options for logging
loggerLogger that will receive each logged message
Returns
Error code

◆ rodbus_data_bits_to_string()

static const char * rodbus_data_bits_to_string ( rodbus_data_bits_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_database_add_coil()

bool rodbus_database_add_coil ( rodbus_database_t instance,
uint16_t  index,
bool  value 
)

Add a new coil to the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the coil
valueInitial value of the coil
Returns
true if the value is new, false otherwise

◆ rodbus_database_add_discrete_input()

bool rodbus_database_add_discrete_input ( rodbus_database_t instance,
uint16_t  index,
bool  value 
)

Add a new discrete input to the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the discrete input
valueInitial value of the discrete input
Returns
true if the value is new, false otherwise

◆ rodbus_database_add_holding_register()

bool rodbus_database_add_holding_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t  value 
)

Add a new holding register to the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the holding register
valueInitial value of the holding register
Returns
true if the value is new, false otherwise

◆ rodbus_database_add_input_register()

bool rodbus_database_add_input_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t  value 
)

Add a new input register to the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the input register
valueInitial value of the input register
Returns
true if the value is new, false otherwise

◆ rodbus_database_delete_coil()

bool rodbus_database_delete_coil ( rodbus_database_t instance,
uint16_t  index 
)

Remove a coil address from the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the coil
Returns
true if the value is new, false otherwise

◆ rodbus_database_delete_discrete_input()

bool rodbus_database_delete_discrete_input ( rodbus_database_t instance,
uint16_t  index 
)

Remove a discrete input address from the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the discrete input
Returns
true if the value is new, false otherwise

◆ rodbus_database_delete_holding_register()

bool rodbus_database_delete_holding_register ( rodbus_database_t instance,
uint16_t  index 
)

Remove a holding register address from the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the holding register
Returns
true if the value is new, false otherwise

◆ rodbus_database_delete_input_register()

bool rodbus_database_delete_input_register ( rodbus_database_t instance,
uint16_t  index 
)

Remove a input register address from the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the input register
Returns
true if the value is new, false otherwise

◆ rodbus_database_get_coil()

rodbus_param_error_t rodbus_database_get_coil ( rodbus_database_t instance,
uint16_t  index,
bool *  out 
)

Get the current coil value of the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the coil
outCurrent value of the point
Returns
Error code

◆ rodbus_database_get_discrete_input()

rodbus_param_error_t rodbus_database_get_discrete_input ( rodbus_database_t instance,
uint16_t  index,
bool *  out 
)

Get the current discrete input value of the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the discrete input
outCurrent value of the point
Returns
Error code

◆ rodbus_database_get_holding_register()

rodbus_param_error_t rodbus_database_get_holding_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t *  out 
)

Get the current holding register value of the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the holding register
outCurrent value of the point
Returns
Error code

◆ rodbus_database_get_input_register()

rodbus_param_error_t rodbus_database_get_input_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t *  out 
)

Get the current input register value of the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the input register
outCurrent value of the point
Returns
Error code

◆ rodbus_database_update_coil()

bool rodbus_database_update_coil ( rodbus_database_t instance,
uint16_t  index,
bool  value 
)

Update the current value of a coil in the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the coil
valueNew value of the coil
Returns
true if the address is defined, false otherwise

◆ rodbus_database_update_discrete_input()

bool rodbus_database_update_discrete_input ( rodbus_database_t instance,
uint16_t  index,
bool  value 
)

Update the current value of a discrete input in the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the discrete input
valueNew value of the discrete input
Returns
true if the address is defined, false otherwise

◆ rodbus_database_update_holding_register()

bool rodbus_database_update_holding_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t  value 
)

Update the current value of a holding register in the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the holding register
valueNew value of the holding register
Returns
true if the address is defined, false otherwise

◆ rodbus_database_update_input_register()

bool rodbus_database_update_input_register ( rodbus_database_t instance,
uint16_t  index,
uint16_t  value 
)

Update the current value of a input register in the database.

Parameters
instanceInstance of rodbus_database_t
indexAddress of the input register
valueNew value of the input register
Returns
true if the address is defined, false otherwise

◆ rodbus_decode_level_build()

static rodbus_decode_level_t rodbus_decode_level_build ( rodbus_app_decode_level_t  app,
rodbus_frame_decode_level_t  frame,
rodbus_phys_decode_level_t  physical 
)
static

Fully construct rodbus_decode_level_t specifying the value of each field.

Parameters
appControls decoding of the application layer (PDU)
frameControls decoding of frames (MBAP / Serial PDU)
physicalControls the logging of physical layer read/write
Returns
New instance of rodbus_decode_level_t

◆ rodbus_decode_level_nothing()

static rodbus_decode_level_t rodbus_decode_level_nothing ( )
static

◆ rodbus_device_map_add_endpoint()

bool rodbus_device_map_add_endpoint ( rodbus_device_map_t instance,
uint8_t  unit_id,
rodbus_write_handler_t  handler,
rodbus_database_callback_t  configure 
)

Add an endpoint to the map.

Parameters
instanceInstance of rodbus_device_map_t
unit_idUnit id of the endpoint
handlerCallback interface for handling write operations for this device
configureOne-time callback interface configuring the initial state of the database
Returns
True if the unit id doesn't already exists, false otherwise

◆ rodbus_device_map_create()

rodbus_device_map_t * rodbus_device_map_create ( )

Create a device map that will be used to bind devices to a server endpoint.

Returns
Instance of rodbus_device_map_t

◆ rodbus_device_map_destroy()

void rodbus_device_map_destroy ( rodbus_device_map_t instance)

Destroy a previously created device map.

Parameters
instanceInstance of rodbus_device_map_t to destroy

◆ rodbus_flow_control_to_string()

static const char * rodbus_flow_control_to_string ( rodbus_flow_control_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_frame_decode_level_to_string()

static const char * rodbus_frame_decode_level_to_string ( rodbus_frame_decode_level_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_log_level_to_string()

static const char * rodbus_log_level_to_string ( rodbus_log_level_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_log_output_format_to_string()

static const char * rodbus_log_output_format_to_string ( rodbus_log_output_format_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_logging_config_init()

◆ rodbus_min_tls_version_to_string()

static const char * rodbus_min_tls_version_to_string ( rodbus_min_tls_version_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_modbus_exception_to_string()

static const char * rodbus_modbus_exception_to_string ( rodbus_modbus_exception_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_nothing_to_string()

static const char * rodbus_nothing_to_string ( rodbus_nothing_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_param_error_to_string()

static const char * rodbus_param_error_to_string ( rodbus_param_error_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_parity_to_string()

static const char * rodbus_parity_to_string ( rodbus_parity_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_phys_decode_level_to_string()

static const char * rodbus_phys_decode_level_to_string ( rodbus_phys_decode_level_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_port_state_to_string()

static const char * rodbus_port_state_to_string ( rodbus_port_state_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_register_list_add()

void rodbus_register_list_add ( rodbus_register_list_t instance,
uint16_t  value 
)

Add a value to the collection.

Parameters
instanceinstance to which to add the value
valuevalue to add to the instance

◆ rodbus_register_list_create()

rodbus_register_list_t * rodbus_register_list_create ( uint32_t  reserve_size)

Creates an instance of the collection.

Parameters
reserve_sizepreallocate a particular size
Returns
Allocated opaque collection instance

◆ rodbus_register_list_destroy()

void rodbus_register_list_destroy ( rodbus_register_list_t instance)

Destroys an instance of the collection.

Parameters
instanceinstance to destroy

◆ rodbus_register_value_init()

static rodbus_register_value_t rodbus_register_value_init ( uint16_t  index,
uint16_t  value 
)
static

Fully construct rodbus_register_value_t specifying the value of each field.

Parameters
indexIndex of register
valueValue of the register
Returns
New instance of rodbus_register_value_t

◆ rodbus_register_value_iterator_next()

rodbus_register_value_t * rodbus_register_value_iterator_next ( rodbus_register_value_iterator_t iter)

returns a pointer to the next value or NULL

Parameters
iteropaque iterator on which to retrieve the next value
Returns
next value or NULL

◆ rodbus_request_error_to_string()

static const char * rodbus_request_error_to_string ( rodbus_request_error_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_request_param_init()

static rodbus_request_param_t rodbus_request_param_init ( uint8_t  unit_id,
uint64_t  timeout 
)
static

Fully construct rodbus_request_param_t specifying the value of each field.

Parameters
unit_idModbus address for the request
timeoutResponse timeout for the request
Returns
New instance of rodbus_request_param_t

◆ rodbus_retry_strategy_init()

static rodbus_retry_strategy_t rodbus_retry_strategy_init ( )
static

Initialize a retry strategy to defaults.

Note
Values are initialized to:
Returns
New instance of rodbus_retry_strategy_t

◆ rodbus_runtime_config_init()

static rodbus_runtime_config_t rodbus_runtime_config_init ( )
static

Initialize the configuration to default values.

Note
Values are initialized to:
Returns
New instance of rodbus_runtime_config_t

◆ rodbus_runtime_create()

rodbus_param_error_t rodbus_runtime_create ( rodbus_runtime_config_t  config,
rodbus_runtime_t **  out 
)

Creates a new runtime for running the protocol stack.

Warning
The runtime should be kept alive for as long as it's needed and it should be released with rodbus_runtime_destroy
Parameters
configRuntime configuration
outInstance of rodbus_runtime_t
Returns
Error code

◆ rodbus_runtime_destroy()

void rodbus_runtime_destroy ( rodbus_runtime_t instance)

Destroy a runtime.

This method will gracefully wait for all asynchronous operation to end before returning

Parameters
instanceInstance of rodbus_runtime_t to destroy

◆ rodbus_runtime_set_shutdown_timeout()

void rodbus_runtime_set_shutdown_timeout ( rodbus_runtime_t instance,
uint64_t  timeout 
)

By default, when the runtime shuts down, it does so without a timeout and waits indefinitely for all spawned tasks to yield.

Setting this value will put a maximum time bound on the eventual shutdown. Threads that have not exited within this timeout will be terminated.

Warning
This can leak memory. This method should only be used if the the entire application is being shut down so that memory can be cleaned up by the OS.
Parameters
instanceInstance of rodbus_runtime_t
timeoutMaximum number of seconds to wait for the runtime to shut down (seconds)

◆ rodbus_serial_port_settings_init()

◆ rodbus_server_create_rtu()

rodbus_param_error_t rodbus_server_create_rtu ( rodbus_runtime_t runtime,
const char *  path,
rodbus_serial_port_settings_t  serial_params,
rodbus_retry_strategy_t  retry,
rodbus_device_map_t endpoints,
rodbus_decode_level_t  decode_level,
rodbus_server_t **  out 
)

Launch a RTU server.

Parameters
runtimeruntime on which to spawn the server
pathPath to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows.
serial_paramsSerial port settings
retryParameters that control How long to wait before re-opening the serial port
endpointsmap of endpoints which is emptied upon passing to this function
decode_levelDecode levels for this server
outRTU server instance
Returns
Error code

◆ rodbus_server_create_tcp()

rodbus_param_error_t rodbus_server_create_tcp ( rodbus_runtime_t runtime,
const char *  address,
uint16_t  port,
rodbus_address_filter_t filter,
uint16_t  max_sessions,
rodbus_device_map_t endpoints,
rodbus_decode_level_t  decode_level,
rodbus_server_t **  out 
)

Launch a TCP server.

Recommended port for Modbus is 502.

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
max_sessionsMaximum number of concurrent sessions
endpointsMap of endpoints which is emptied upon passing to this function
decode_levelDecode levels for this server
outTCP server instance
Returns
Error code

◆ rodbus_server_create_tls()

rodbus_param_error_t rodbus_server_create_tls ( rodbus_runtime_t runtime,
const char *  address,
uint16_t  port,
rodbus_address_filter_t filter,
uint16_t  max_sessions,
rodbus_device_map_t endpoints,
rodbus_tls_server_config_t  tls_config,
rodbus_decode_level_t  decode_level,
rodbus_server_t **  out 
)

Create a TLS server that does NOT require the client role extension.

This functionality is not standardized by Modbus.org, but nevertheless is commonly implemented

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
max_sessionsMaximum number of concurrent sessions
endpointsmap of endpoints which is emptied upon passing to this function
tls_configTLS server configuration
decode_levelDecode levels for this server
outModbus Security (TLS) server instance
Returns
Error code

◆ rodbus_server_create_tls_with_authz()

rodbus_param_error_t rodbus_server_create_tls_with_authz ( rodbus_runtime_t runtime,
const char *  address,
uint16_t  port,
rodbus_address_filter_t filter,
uint16_t  max_sessions,
rodbus_device_map_t endpoints,
rodbus_tls_server_config_t  tls_config,
rodbus_authorization_handler_t  authorization_handler,
rodbus_decode_level_t  decode_level,
rodbus_server_t **  out 
)

Create a Modbus Security (TLS) server.

This server requires that the client certificate contains the role extension and authorizes each request against the supplied handler.

Recommended port for Modbus Security is 802.

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
max_sessionsMaximum number of concurrent sessions
endpointsmap of endpoints which is emptied upon passing to this function
tls_configTLS server configuration
authorization_handlerAuthorization handler
decode_levelDecode levels for this server
outModbus Security (TLS) server instance
Returns
Error code

◆ rodbus_server_destroy()

void rodbus_server_destroy ( rodbus_server_t instance)

Shutdown and release all resources of a running server.

Parameters
instanceInstance of rodbus_server_t to destroy

◆ rodbus_server_set_decode_level()

rodbus_param_error_t rodbus_server_set_decode_level ( rodbus_server_t instance,
rodbus_decode_level_t  level 
)

Set the decoding level for the server.

Parameters
instanceInstance of rodbus_server_t
levelDecoding level
Returns
Error code

◆ rodbus_server_update_database()

rodbus_param_error_t rodbus_server_update_database ( rodbus_server_t instance,
uint8_t  unit_id,
rodbus_database_callback_t  transaction 
)

Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction.

Parameters
instanceInstance of rodbus_server_t
unit_idUnit id of the database to update
transactionCallback invoked when a lock has been acquired
Returns
Error code

◆ rodbus_stop_bits_to_string()

static const char * rodbus_stop_bits_to_string ( rodbus_stop_bits_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_time_format_to_string()

static const char * rodbus_time_format_to_string ( rodbus_time_format_t  value)
static

Converts the enum to a string.

Parameters
valueEnum to convert
Returns
String representation

◆ rodbus_tls_client_config_init()

static rodbus_tls_client_config_t rodbus_tls_client_config_init ( const char *  dns_name,
const char *  peer_cert_path,
const char *  local_cert_path,
const char *  private_key_path,
const char *  password 
)
static

Initialize a TLS client configuration.

Note
Values are initialized to:
Parameters
dns_nameName expected to be in the presented certificate (only in RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED)
peer_cert_pathPath to the PEM-encoded certificate of the peer
local_cert_pathPath to the PEM-encoded local certificate
private_key_pathPath to the the PEM-encoded private key
passwordOptional password if the private key file is encrypted
Returns
New instance of rodbus_tls_client_config_t

◆ rodbus_tls_server_config_init()

static rodbus_tls_server_config_t rodbus_tls_server_config_init ( const char *  peer_cert_path,
const char *  local_cert_path,
const char *  private_key_path,
const char *  password 
)
static

Initialize a TLS client configuration.

Note
Values are initialized to:
Parameters
peer_cert_pathPath to the PEM-encoded certificate of the peer
local_cert_pathPath to the PEM-encoded local certificate
private_key_pathPath to the the PEM-encoded private key
passwordOptional password if the private key file is encrypted
Returns
New instance of rodbus_tls_server_config_t

◆ rodbus_version()

const char * rodbus_version ( )

Get the version of the library as a string.

Returns
Version number

◆ rodbus_write_result_exception_init()

static rodbus_write_result_t rodbus_write_result_exception_init ( rodbus_modbus_exception_t  exception)
static

Initialize a rodbus_write_result_t to indicate a standard Modbus exception.

Note
Values are initialized to:
Parameters
exceptionException enumeration. If RODBUS_MODBUS_EXCEPTION_UNKNOWN, look at the raw value
Returns
New instance of rodbus_write_result_t

◆ rodbus_write_result_raw_exception_init()

static rodbus_write_result_t rodbus_write_result_raw_exception_init ( uint8_t  raw_exception)
static

Initialize a rodbus_write_result_t to indicate a non-standard Modbus exception.

Note
Values are initialized to:
Parameters
raw_exceptionRaw exception value when rodbus_write_result_t::exception field is RODBUS_MODBUS_EXCEPTION_UNKNOWN
Returns
New instance of rodbus_write_result_t

◆ rodbus_write_result_success_init()

static rodbus_write_result_t rodbus_write_result_success_init ( )
static

Initialize a rodbus_write_result_t to indicate a successful write operation.

Note
Values are initialized to:
Returns
New instance of rodbus_write_result_t