12#define RODBUS_VERSION_MAJOR 1
13#define RODBUS_VERSION_MINOR 6
14#define RODBUS_VERSION_PATCH 0
15#define RODBUS_VERSION_STRING "1.6.0-RC1"
111 default:
return "unknown param_error value";
131 default:
return "unknown nothing value";
161 default:
return "unknown app_decode_level value";
190 default:
return "unknown frame_decode_level value";
215 default:
return "unknown phys_decode_level value";
244 return _return_value;
262 return _return_value;
289 return _return_value;
316 return _return_value;
345 return _return_value;
447 default:
return "unknown request_error value";
473 return _return_value;
499 return _return_value;
563 default:
return "unknown modbus_exception value";
591 default:
return "unknown data_bits value";
616 default:
return "unknown flow_control value";
641 default:
return "unknown parity value";
663 default:
return "unknown stop_bits value";
705 return _return_value;
729 default:
return "unknown min_tls_version value";
759 default:
return "unknown certificate_mode value";
791 return _return_value;
824 default:
return "unknown log_level value";
848 default:
return "unknown log_output_format value";
873 default:
return "unknown time_format value";
911 return _return_value;
999 return _return_value;
1035 default:
return "unknown client_state value";
1080 default:
return "unknown port_state value";
1492 return _return_value;
1510 return _return_value;
1528 return _return_value;
1638 return _return_value;
1660 default:
return "unknown authorization value";
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.
Definition: rodbus.h:283
static const char * rodbus_request_error_to_string(rodbus_request_error_t value)
Converts the enum to a string.
Definition: rodbus.h:423
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.
rodbus_port_state_t
State of the serial port.
Definition: rodbus.h:1058
@ RODBUS_PORT_STATE_OPEN
Port is open.
Definition: rodbus.h:1064
@ RODBUS_PORT_STATE_DISABLED
Disabled until enabled.
Definition: rodbus.h:1060
@ RODBUS_PORT_STATE_WAIT
Waiting to perform an open retry.
Definition: rodbus.h:1062
@ RODBUS_PORT_STATE_SHUTDOWN
Task has been shut down.
Definition: rodbus.h:1066
rodbus_register_list_t * rodbus_register_list_create(uint32_t reserve_size)
Creates an instance of the collection.
rodbus_log_output_format_t
Describes how each log event is formatted.
Definition: rodbus.h:832
@ RODBUS_LOG_OUTPUT_FORMAT_TEXT
A simple text-based format.
Definition: rodbus.h:834
@ RODBUS_LOG_OUTPUT_FORMAT_JSON
Output formatted as JSON.
Definition: rodbus.h:836
void rodbus_register_list_add(rodbus_register_list_t *instance, uint16_t value)
Add a value to the collection.
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.
void rodbus_runtime_destroy(rodbus_runtime_t *instance)
Destroy a runtime.
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.
static const char * rodbus_certificate_mode_to_string(rodbus_certificate_mode_t value)
Converts the enum to a string.
Definition: rodbus.h:753
rodbus_min_tls_version_t
Minimum TLS version to allow.
Definition: rodbus.h:711
@ RODBUS_MIN_TLS_VERSION_V13
Allow only TLS 1.3.
Definition: rodbus.h:717
@ RODBUS_MIN_TLS_VERSION_V12
Allow TLS 1.2 and TLS 1.3.
Definition: rodbus.h:713
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.
Definition: rodbus.h:467
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.
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.
static const char * rodbus_modbus_exception_to_string(rodbus_modbus_exception_t value)
Converts the enum to a string.
Definition: rodbus.h:549
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.
Definition: rodbus.h:493
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.
struct rodbus_runtime_t rodbus_runtime_t
Handle to the underlying runtime.
Definition: rodbus.h:321
void rodbus_bit_list_add(rodbus_bit_list_t *instance, bool value)
Add a value to the collection.
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 ...
static const char * rodbus_data_bits_to_string(rodbus_data_bits_t value)
Converts the enum to a string.
Definition: rodbus.h:583
rodbus_flow_control_t
Flow control modes.
Definition: rodbus.h:597
@ RODBUS_FLOW_CONTROL_SOFTWARE
Flow control using XON/XOFF bytes.
Definition: rodbus.h:601
@ RODBUS_FLOW_CONTROL_HARDWARE
Flow control using RTS/CTS signals.
Definition: rodbus.h:603
@ RODBUS_FLOW_CONTROL_NONE
No flow control.
Definition: rodbus.h:599
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.
Definition: rodbus.h:1503
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.
void rodbus_bit_list_destroy(rodbus_bit_list_t *instance)
Destroys an instance of the collection.
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.
rodbus_bit_list_t * rodbus_bit_list_create(uint32_t reserve_size)
Creates an instance of the collection.
rodbus_frame_decode_level_t
Controls how the transmitted and received frames are decoded at the INFO log level.
Definition: rodbus.h:171
@ RODBUS_FRAME_DECODE_LEVEL_PAYLOAD
Decode the header and the raw payload as hexadecimal.
Definition: rodbus.h:177
@ RODBUS_FRAME_DECODE_LEVEL_NOTHING
Log nothing.
Definition: rodbus.h:173
@ RODBUS_FRAME_DECODE_LEVEL_HEADER
Decode the header.
Definition: rodbus.h:175
bool rodbus_database_add_coil(rodbus_database_t *instance, uint16_t index, bool value)
Add a new coil to the database.
struct rodbus_server_t rodbus_server_t
Handle to the running server. The server runs on a background task until this class is destroyed.
Definition: rodbus.h:1771
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.
static const char * rodbus_parity_to_string(rodbus_parity_t value)
Converts the enum to a string.
Definition: rodbus.h:634
static const char * rodbus_flow_control_to_string(rodbus_flow_control_t value)
Converts the enum to a string.
Definition: rodbus.h:609
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.
Definition: rodbus.h:237
bool rodbus_database_delete_coil(rodbus_database_t *instance, uint16_t index)
Remove a coil address from the database.
static const char * rodbus_frame_decode_level_to_string(rodbus_frame_decode_level_t value)
Converts the enum to a string.
Definition: rodbus.h:183
bool rodbus_database_add_holding_register(rodbus_database_t *instance, uint16_t index, uint16_t value)
Add a new holding register to the database.
rodbus_request_error_t
Error information returned from asynchronous functions calls.
Definition: rodbus.h:377
@ RODBUS_REQUEST_ERROR_NO_CONNECTION
The channel had no connection (or open serial port) for the request: it was disabled,...
Definition: rodbus.h:383
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_UNKNOWN
The status code is not defined in the Modbus specification, refer to the raw exception code to see wh...
Definition: rodbus.h:417
@ RODBUS_REQUEST_ERROR_BAD_REQUEST
The request was invalid.
Definition: rodbus.h:387
@ RODBUS_REQUEST_ERROR_OK
Success, i.e. no error occurred.
Definition: rodbus.h:379
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE
An unrecoverable error occurred while the server was attempting to perform the requested action.
Definition: rodbus.h:405
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR
Specialized use in conjunction with function codes 20 and 21 and reference type 6,...
Definition: rodbus.h:411
@ RODBUS_REQUEST_ERROR_SHUTDOWN
The channel was shutdown before the operation could complete.
Definition: rodbus.h:381
@ RODBUS_REQUEST_ERROR_RESPONSE_TIMEOUT
No valid response was received before the timeout.
Definition: rodbus.h:385
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY
Specialized use in conjunction with programming commands. The server is engaged in processing a long-...
Definition: rodbus.h:409
@ RODBUS_REQUEST_ERROR_BAD_ARGUMENT
An invalid argument was supplied and the request could not be performed.
Definition: rodbus.h:397
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_FUNCTION
The data address received in the query is not an allowable address for the server.
Definition: rodbus.h:399
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ACKNOWLEDGE
Specialized use in conjunction with programming commands. The server has accepted the request and is ...
Definition: rodbus.h:407
@ RODBUS_REQUEST_ERROR_BAD_RESPONSE
The response from the server was received but was improperly formatted.
Definition: rodbus.h:389
@ RODBUS_REQUEST_ERROR_INTERNAL_ERROR
An unspecified internal error occurred while performing the request.
Definition: rodbus.h:395
@ 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...
Definition: rodbus.h:415
@ RODBUS_REQUEST_ERROR_IO_ERROR
An I/O error occurred on the underlying stream while performing the request.
Definition: rodbus.h:391
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS
The data address received in the query is not an allowable address for the server.
Definition: rodbus.h:401
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE
Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an in...
Definition: rodbus.h:413
@ RODBUS_REQUEST_ERROR_BAD_FRAMING
A framing error was detected while performing the request.
Definition: rodbus.h:393
@ RODBUS_REQUEST_ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE
A value contained in the request is not an allowable value for server.
Definition: rodbus.h:403
struct rodbus_address_filter_t rodbus_address_filter_t
Filter used to restrict which IP addresses may communicate with a server.
Definition: rodbus.h:1739
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.
Definition: rodbus.h:987
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 server configuration.
Definition: rodbus.h:1628
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.
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.
bool rodbus_database_update_coil(rodbus_database_t *instance, uint16_t index, bool value)
Update the current value of a coil in the database.
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.
struct rodbus_client_channel_t rodbus_client_channel_t
Abstract representation of a client communication channel.
Definition: rodbus.h:945
rodbus_register_value_t * rodbus_register_value_iterator_next(rodbus_register_value_iterator_t *iter)
returns a pointer to the next value or NULL
bool rodbus_database_delete_holding_register(rodbus_database_t *instance, uint16_t index)
Remove a holding register address from the database.
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.
static rodbus_serial_port_settings_t rodbus_serial_port_settings_init()
Initialize a serial port configuration.
Definition: rodbus.h:696
rodbus_param_error_t rodbus_client_channel_enable(rodbus_client_channel_t *instance)
Enable channel communications.
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 an...
bool rodbus_database_delete_discrete_input(rodbus_database_t *instance, uint16_t index)
Remove a discrete input address from the database.
rodbus_param_error_t rodbus_client_channel_disable(rodbus_client_channel_t *instance)
Disable channel communications.
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.
void rodbus_client_channel_destroy(rodbus_client_channel_t *instance)
Shutdown a rodbus_client_channel_t and release all resources.
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.
static const char * rodbus_param_error_to_string(rodbus_param_error_t value)
Converts the enum to a string.
Definition: rodbus.h:86
rodbus_stop_bits_t
Number of stop bits.
Definition: rodbus.h:647
@ RODBUS_STOP_BITS_TWO
Two stop bits.
Definition: rodbus.h:651
@ RODBUS_STOP_BITS_ONE
One stop bit.
Definition: rodbus.h:649
static rodbus_write_result_t rodbus_write_result_success_init()
Initialize a rodbus_write_result_t to indicate a successful write operation.
Definition: rodbus.h:1485
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.
Definition: rodbus.h:310
rodbus_parity_t
Parity checking modes.
Definition: rodbus.h:622
@ RODBUS_PARITY_ODD
Parity bit sets odd number of 1 bits.
Definition: rodbus.h:626
@ RODBUS_PARITY_NONE
No parity bit.
Definition: rodbus.h:624
@ RODBUS_PARITY_EVEN
Parity bit sets even number of 1 bits.
Definition: rodbus.h:628
rodbus_data_bits_t
Number of bits per character.
Definition: rodbus.h:569
@ RODBUS_DATA_BITS_FIVE
5 bits per character
Definition: rodbus.h:571
@ RODBUS_DATA_BITS_SEVEN
7 bits per character
Definition: rodbus.h:575
@ RODBUS_DATA_BITS_SIX
6 bits per character
Definition: rodbus.h:573
@ RODBUS_DATA_BITS_EIGHT
8 bits per character
Definition: rodbus.h:577
bool rodbus_database_delete_input_register(rodbus_database_t *instance, uint16_t index)
Remove a input register address from the database.
rodbus_bit_value_t * rodbus_bit_value_iterator_next(rodbus_bit_value_iterator_t *iter)
returns a pointer to the next value or NULL
void rodbus_server_destroy(rodbus_server_t *instance)
Shutdown and release all resources of a running server.
bool rodbus_database_add_discrete_input(rodbus_database_t *instance, uint16_t index, bool value)
Add a new discrete input to the database.
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.
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.
static rodbus_decode_level_t rodbus_decode_level_nothing()
Initialize log levels to defaults which is to decode nothing.
Definition: rodbus.h:255
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.
rodbus_time_format_t
Describes if and how the time will be formatted in log messages.
Definition: rodbus.h:854
@ RODBUS_TIME_FORMAT_RFC_3339
Format the time using RFC 3339.
Definition: rodbus.h:858
@ RODBUS_TIME_FORMAT_NONE
Don't format the timestamp as part of the message.
Definition: rodbus.h:856
@ RODBUS_TIME_FORMAT_SYSTEM
Format the time in a human readable format e.g. 'Jun 25 14:27:12.955'.
Definition: rodbus.h:860
rodbus_param_error_t rodbus_address_filter_add(rodbus_address_filter_t *instance, const char *address)
Add an allowed IP address to the filter.
struct rodbus_device_map_t rodbus_device_map_t
Maps endpoint handlers to Modbus address.
Definition: rodbus.h:1575
static const char * rodbus_time_format_to_string(rodbus_time_format_t value)
Converts the enum to a string.
Definition: rodbus.h:866
static rodbus_runtime_config_t rodbus_runtime_config_init()
Initialize the configuration to default values.
Definition: rodbus.h:340
struct rodbus_bit_value_iterator_t rodbus_bit_value_iterator_t
Iterator of bit_value.
Definition: rodbus.h:504
struct rodbus_database_t rodbus_database_t
Class used to add, remove, update, and retrieve values.
Definition: rodbus.h:1334
static const char * rodbus_app_decode_level_to_string(rodbus_app_decode_level_t value)
Converts the enum to a string.
Definition: rodbus.h:153
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.
rodbus_client_state_t
State of the client connection.
Definition: rodbus.h:1007
@ RODBUS_CLIENT_STATE_WAIT_AFTER_FAILED_CONNECT
Failed to establish a connection, waiting before retrying.
Definition: rodbus.h:1015
@ RODBUS_CLIENT_STATE_WAIT_AFTER_DISCONNECT
Client was disconnected, waiting before retrying.
Definition: rodbus.h:1017
@ RODBUS_CLIENT_STATE_CONNECTED
Client is connected to the remote device.
Definition: rodbus.h:1013
@ RODBUS_CLIENT_STATE_DISABLED
Client is disabled and idle until enabled.
Definition: rodbus.h:1009
@ RODBUS_CLIENT_STATE_SHUTDOWN
Client is shutting down.
Definition: rodbus.h:1019
@ RODBUS_CLIENT_STATE_CONNECTING
Client is trying to establish a connection to the remote device.
Definition: rodbus.h:1011
static const char * rodbus_port_state_to_string(rodbus_port_state_t value)
Converts the enum to a string.
Definition: rodbus.h:1072
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.
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.
struct rodbus_register_list_t rodbus_register_list_t
Collection of register_list.
Definition: rodbus.h:1286
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.
static const char * rodbus_nothing_to_string(rodbus_nothing_t value)
Converts the enum to a string.
Definition: rodbus.h:126
struct rodbus_bit_list_t rodbus_bit_list_t
Collection of bit_list.
Definition: rodbus.h:1259
static const char * rodbus_log_level_to_string(rodbus_log_level_t value)
Converts the enum to a string.
Definition: rodbus.h:815
static const char * rodbus_phys_decode_level_to_string(rodbus_phys_decode_level_t value)
Converts the enum to a string.
Definition: rodbus.h:208
static const char * rodbus_min_tls_version_to_string(rodbus_min_tls_version_t value)
Converts the enum to a string.
Definition: rodbus.h:723
static const char * rodbus_authorization_to_string(rodbus_authorization_t value)
Converts the enum to a string.
Definition: rodbus.h:1654
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.
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.
void rodbus_device_map_destroy(rodbus_device_map_t *instance)
Destroy a previously created device map.
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.
static rodbus_retry_strategy_t rodbus_retry_strategy_init()
Initialize a retry strategy to defaults.
Definition: rodbus.h:785
rodbus_address_filter_t * rodbus_address_filter_any()
Create an address filter that accepts any IP address.
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.
rodbus_modbus_exception_t
Error information returned during asynchronous API calls.
Definition: rodbus.h:523
@ RODBUS_MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND
Specialized use in conjunction with gateways, indicates that no response was obtained from the target...
Definition: rodbus.h:541
@ RODBUS_MODBUS_EXCEPTION_UNKNOWN
The status code is not defined in the Modbus specification, refer to the raw exception code to see wh...
Definition: rodbus.h:543
@ RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_BUSY
Specialized use in conjunction with programming commands. The server is engaged in processing a long-...
Definition: rodbus.h:535
@ RODBUS_MODBUS_EXCEPTION_MEMORY_PARITY_ERROR
Specialized use in conjunction with function codes 20 and 21 and reference type 6,...
Definition: rodbus.h:537
@ RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE
A value contained in the request is not an allowable value for server.
Definition: rodbus.h:529
@ RODBUS_MODBUS_EXCEPTION_ACKNOWLEDGE
Specialized use in conjunction with programming commands. The server has accepted the request and is ...
Definition: rodbus.h:533
@ RODBUS_MODBUS_EXCEPTION_SERVER_DEVICE_FAILURE
An unrecoverable error occurred while the server was attempting to perform the requested action.
Definition: rodbus.h:531
@ RODBUS_MODBUS_EXCEPTION_ILLEGAL_FUNCTION
The data address received in the query is not an allowable address for the server.
Definition: rodbus.h:525
@ RODBUS_MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE
Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an in...
Definition: rodbus.h:539
@ RODBUS_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS
The data address received in the query is not an allowable address for the server.
Definition: rodbus.h:527
rodbus_authorization_t
Authorization result used by rodbus_authorization_handler_t.
Definition: rodbus.h:1644
@ RODBUS_AUTHORIZATION_DENY
Client is NOT authorized to perform the operation.
Definition: rodbus.h:1648
@ RODBUS_AUTHORIZATION_ALLOW
Client is authorized to perform the operation.
Definition: rodbus.h:1646
static const char * rodbus_client_state_to_string(rodbus_client_state_t value)
Converts the enum to a string.
Definition: rodbus.h:1025
rodbus_phys_decode_level_t
Controls how data transmitted at the physical layer (TCP, serial, etc) is logged.
Definition: rodbus.h:196
@ RODBUS_PHYS_DECODE_LEVEL_DATA
Log the length and the actual data that is sent and received.
Definition: rodbus.h:202
@ RODBUS_PHYS_DECODE_LEVEL_LENGTH
Log only the length of data that is sent and received.
Definition: rodbus.h:200
@ RODBUS_PHYS_DECODE_LEVEL_NOTHING
Log nothing.
Definition: rodbus.h:198
rodbus_device_map_t * rodbus_device_map_create()
Create a device map that will be used to bind devices to a server endpoint.
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.
bool rodbus_database_add_input_register(rodbus_database_t *instance, uint16_t index, uint16_t value)
Add a new input register to the database.
void rodbus_register_list_destroy(rodbus_register_list_t *instance)
Destroys an instance of the collection.
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.
Definition: rodbus.h:1521
const char * rodbus_version()
Get the version of the library as a string.
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.
rodbus_param_error_t
Error type that indicates a bad parameter or bad programmer logic.
Definition: rodbus.h:38
@ RODBUS_PARAM_ERROR_OK
Success, i.e. no error occurred.
Definition: rodbus.h:40
@ RODBUS_PARAM_ERROR_INVALID_UTF8
String argument was not valid UTF-8.
Definition: rodbus.h:78
@ RODBUS_PARAM_ERROR_RUNTIME_CANNOT_BLOCK_WITHIN_ASYNC
Runtime cannot execute blocking call within asynchronous context.
Definition: rodbus.h:52
@ RODBUS_PARAM_ERROR_INVALID_RANGE
Invalid Modbus address range.
Definition: rodbus.h:56
@ RODBUS_PARAM_ERROR_INVALID_LOCAL_CERTIFICATE
Invalid local certificate file.
Definition: rodbus.h:68
@ RODBUS_PARAM_ERROR_INVALID_REQUEST
Invalid Modbus request.
Definition: rodbus.h:58
@ RODBUS_PARAM_ERROR_INVALID_INDEX
Invalid index.
Definition: rodbus.h:60
@ RODBUS_PARAM_ERROR_INVALID_PRIVATE_KEY
Invalid private key file.
Definition: rodbus.h:70
@ RODBUS_PARAM_ERROR_SERVER_BIND_ERROR
Server failed to bind to the specified port.
Definition: rodbus.h:62
@ RODBUS_PARAM_ERROR_RUNTIME_CREATION_FAILURE
Failed to create Tokio runtime.
Definition: rodbus.h:48
@ RODBUS_PARAM_ERROR_INVALID_DNS_NAME
Invalid DNS name.
Definition: rodbus.h:72
@ RODBUS_PARAM_ERROR_INVALID_IP_ADDRESS
Invalid IP address.
Definition: rodbus.h:54
@ RODBUS_PARAM_ERROR_NULL_PARAMETER
Null parameter.
Definition: rodbus.h:44
@ RODBUS_PARAM_ERROR_SHUTDOWN
The task has been shutdown.
Definition: rodbus.h:76
@ RODBUS_PARAM_ERROR_BAD_TLS_CONFIG
Bad TLS configuration.
Definition: rodbus.h:74
@ RODBUS_PARAM_ERROR_INVALID_PEER_CERTIFICATE
Invalid peer certificate file.
Definition: rodbus.h:66
@ RODBUS_PARAM_ERROR_TOO_MANY_REQUESTS
Number of requests exceeds configured limit.
Definition: rodbus.h:80
@ RODBUS_PARAM_ERROR_LOGGING_ALREADY_CONFIGURED
Logging can only be configured once.
Definition: rodbus.h:46
@ RODBUS_PARAM_ERROR_RUNTIME_DESTROYED
Runtime was already disposed of.
Definition: rodbus.h:50
@ RODBUS_PARAM_ERROR_NO_SUPPORT
The FFI library was compiled without support for this feature.
Definition: rodbus.h:42
@ RODBUS_PARAM_ERROR_INVALID_UNIT_ID
The specified unit id is not associated to this server.
Definition: rodbus.h:64
static const char * rodbus_stop_bits_to_string(rodbus_stop_bits_t value)
Converts the enum to a string.
Definition: rodbus.h:657
void rodbus_address_filter_destroy(rodbus_address_filter_t *instance)
Destroy an address filter.
static const char * rodbus_log_output_format_to_string(rodbus_log_output_format_t value)
Converts the enum to a string.
Definition: rodbus.h:842
rodbus_log_level_t
Log level.
Definition: rodbus.h:799
@ RODBUS_LOG_LEVEL_ERROR
Error log level.
Definition: rodbus.h:801
@ RODBUS_LOG_LEVEL_INFO
Information log level.
Definition: rodbus.h:805
@ RODBUS_LOG_LEVEL_TRACE
Trace log level.
Definition: rodbus.h:809
@ RODBUS_LOG_LEVEL_DEBUG
Debugging log level.
Definition: rodbus.h:807
@ RODBUS_LOG_LEVEL_WARN
Warning log level.
Definition: rodbus.h:803
rodbus_certificate_mode_t
Determines how the certificate(s) presented by the peer are validated.
Definition: rodbus.h:737
@ RODBUS_CERTIFICATE_MODE_SELF_SIGNED
Validates that the peer presents a single certificate which is a byte-for-byte match against the conf...
Definition: rodbus.h:747
@ RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED
Validates the peer certificate against one or more configured trust anchors.
Definition: rodbus.h:743
static rodbus_logging_config_t rodbus_logging_config_init()
Initialize the configuration to default values.
Definition: rodbus.h:902
rodbus_nothing_t
A single value enum which is used as a placeholder for futures that don't return a value.
Definition: rodbus.h:118
@ RODBUS_NOTHING_NOTHING
the only value this enum has
Definition: rodbus.h:120
rodbus_app_decode_level_t
Controls how transmitted and received message at the application layer are decoded at the INFO log le...
Definition: rodbus.h:139
@ RODBUS_APP_DECODE_LEVEL_DATA_VALUES
Decode the function code, the general description of the data and the actual data values.
Definition: rodbus.h:147
@ RODBUS_APP_DECODE_LEVEL_NOTHING
Decode nothing.
Definition: rodbus.h:141
@ RODBUS_APP_DECODE_LEVEL_FUNCTION_CODE
Decode the function code only.
Definition: rodbus.h:143
@ RODBUS_APP_DECODE_LEVEL_DATA_HEADERS
Decode the function code and the general description of the data.
Definition: rodbus.h:145
struct rodbus_register_value_iterator_t rodbus_register_value_iterator_t
Iterator of register_value.
Definition: rodbus.h:513
Range of 16-bit addresses sent in a request from the client to the server.
Definition: rodbus.h:456
uint16_t start
Starting address of the range.
Definition: rodbus.h:458
uint16_t count
Number of addresses in the range.
Definition: rodbus.h:460
User implemented interface defines which request and roles are allowed for different functions when i...
Definition: rodbus.h:1666
rodbus_authorization_t(* write_single_coil)(uint8_t, uint16_t, const char *, void *)
Authorize a Write Single Coil request.
Definition: rodbus.h:1706
rodbus_authorization_t(* write_multiple_registers)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Write Multiple Registers request.
Definition: rodbus.h:1730
rodbus_authorization_t(* read_input_registers)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Read Input Registers request.
Definition: rodbus.h:1698
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1733
rodbus_authorization_t(* read_coils)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Read Coils request.
Definition: rodbus.h:1674
rodbus_authorization_t(* read_holding_registers)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Read Holding Registers request.
Definition: rodbus.h:1690
void * ctx
Context data.
Definition: rodbus.h:1735
rodbus_authorization_t(* write_single_register)(uint8_t, uint16_t, const char *, void *)
Authorize a Write Single Register request.
Definition: rodbus.h:1714
rodbus_authorization_t(* write_multiple_coils)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Write Multiple Coils request.
Definition: rodbus.h:1722
rodbus_authorization_t(* read_discrete_inputs)(uint8_t, rodbus_address_range_t, const char *, void *)
Authorize a Read Discrete Inputs request.
Definition: rodbus.h:1682
Callbacks received when reading coils or discrete inputs.
Definition: rodbus.h:1150
void(* on_complete)(rodbus_bit_value_iterator_t *, void *)
Invoked when the asynchronous operation completes successfully.
Definition: rodbus.h:1155
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1163
void * ctx
Context data.
Definition: rodbus.h:1165
void(* on_failure)(rodbus_request_error_t, void *)
Invoked when the asynchronous operation fails.
Definition: rodbus.h:1160
Bit value and its address.
Definition: rodbus.h:272
bool value
Value of the bit.
Definition: rodbus.h:276
uint16_t index
Address of the bit.
Definition: rodbus.h:274
Callback for monitoring the state of a TCP/TLS connection state.
Definition: rodbus.h:1041
void(* on_change)(rodbus_client_state_t, void *)
Called when the client state changed.
Definition: rodbus.h:1046
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1049
void * ctx
Context data.
Definition: rodbus.h:1051
Callback used to access the internal database while it is locked.
Definition: rodbus.h:1447
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1455
void(* callback)(rodbus_database_t *, void *)
callback function
Definition: rodbus.h:1452
void * ctx
Context data.
Definition: rodbus.h:1457
Controls the decoding of transmitted and received data at the application, frame, and physical layer.
Definition: rodbus.h:223
rodbus_app_decode_level_t app
Controls decoding of the application layer (PDU)
Definition: rodbus.h:225
rodbus_frame_decode_level_t frame
Controls decoding of frames (MBAP / Serial PDU)
Definition: rodbus.h:227
rodbus_phys_decode_level_t physical
Controls the logging of physical layer read/write.
Definition: rodbus.h:229
Logging interface that receives the log messages and writes them somewhere.
Definition: rodbus.h:917
void(* on_message)(rodbus_log_level_t, const char *, void *)
Called when a log message was received and should be logged.
Definition: rodbus.h:923
void * ctx
Context data.
Definition: rodbus.h:928
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:926
Logging configuration options.
Definition: rodbus.h:879
bool print_module_info
optionally print the underlying Rust module information to the message string
Definition: rodbus.h:889
rodbus_time_format_t time_format
optional time format
Definition: rodbus.h:885
rodbus_log_output_format_t output_format
output formatting options
Definition: rodbus.h:883
rodbus_log_level_t level
logging level
Definition: rodbus.h:881
bool print_level
optionally print the log level as part to the message string
Definition: rodbus.h:887
Callback interface for receiving updates about the state of a serial port.
Definition: rodbus.h:1086
void(* on_change)(rodbus_port_state_t, void *)
Invoked when the serial port changes state.
Definition: rodbus.h:1091
void * ctx
Context data.
Definition: rodbus.h:1096
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1094
Callbacks received when reading holding or input registers.
Definition: rodbus.h:1172
void(* on_complete)(rodbus_register_value_iterator_t *, void *)
Invoked when the asynchronous operation completes successfully.
Definition: rodbus.h:1177
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1185
void * ctx
Context data.
Definition: rodbus.h:1187
void(* on_failure)(rodbus_request_error_t, void *)
Invoked when the asynchronous operation fails.
Definition: rodbus.h:1182
Register value and its address.
Definition: rodbus.h:299
uint16_t index
Address of the register.
Definition: rodbus.h:301
uint16_t value
Value of the register.
Definition: rodbus.h:303
Address and timeout parameters for requests.
Definition: rodbus.h:481
uint64_t timeout
Response timeout for the request. It covers sending the request and receiving the response....
Definition: rodbus.h:486
uint8_t unit_id
Modbus address for the request.
Definition: rodbus.h:483
Retry strategy configuration.
Definition: rodbus.h:769
uint64_t max_delay
Maximum delay between two retries.
Definition: rodbus.h:775
uint64_t min_delay
Minimum delay between two retries.
Definition: rodbus.h:772
Runtime configuration.
Definition: rodbus.h:327
uint16_t num_core_threads
Number of runtime threads to spawn. For a guess of the number of CPU cores, use 0.
Definition: rodbus.h:331
Serial port settings.
Definition: rodbus.h:671
rodbus_stop_bits_t stop_bits
Number of bits to use to signal the end of a character.
Definition: rodbus.h:683
rodbus_data_bits_t data_bits
Number of bits used to represent a character sent on the line.
Definition: rodbus.h:677
rodbus_flow_control_t flow_control
Type of signalling to use for controlling data transfer.
Definition: rodbus.h:679
uint32_t baud_rate
Baud rate (in symbols-per-second)
Definition: rodbus.h:675
rodbus_parity_t parity
Type of parity to use for error checking.
Definition: rodbus.h:681
TLS client configuration.
Definition: rodbus.h:951
bool allow_server_name_wildcard
If set to true, a '*' may be used for rodbus_tls_client_config_t::dns_name to bypass server name vali...
Definition: rodbus.h:971
rodbus_certificate_mode_t certificate_mode
Certificate validation mode.
Definition: rodbus.h:969
const char * peer_cert_path
Path to the PEM-encoded trusted CA certificate(s) in RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED mode,...
Definition: rodbus.h:955
rodbus_min_tls_version_t min_tls_version
Minimum TLS version allowed.
Definition: rodbus.h:967
const char * dns_name
Name expected to be in the presented certificate (only in RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED)
Definition: rodbus.h:953
const char * private_key_path
Path to the PEM-encoded private key.
Definition: rodbus.h:959
const char * local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.h:957
const char * password
Optional password if the private key file is encrypted.
Definition: rodbus.h:965
TLS server configuration.
Definition: rodbus.h:1598
const char * password
Optional password if the private key file is encrypted.
Definition: rodbus.h:1610
rodbus_certificate_mode_t certificate_mode
Certificate validation mode.
Definition: rodbus.h:1614
const char * private_key_path
Path to the PEM-encoded private key.
Definition: rodbus.h:1604
const char * local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.h:1602
const char * peer_cert_path
Path to the PEM-encoded trusted CA certificate(s) in RODBUS_CERTIFICATE_MODE_AUTHORITY_BASED mode,...
Definition: rodbus.h:1600
rodbus_min_tls_version_t min_tls_version
Minimum TLS version allowed.
Definition: rodbus.h:1612
Callback methods received from asynchronous write operations.
Definition: rodbus.h:1192
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1205
void * ctx
Context data.
Definition: rodbus.h:1207
void(* on_failure)(rodbus_request_error_t, void *)
Invoked when the asynchronous operation fails.
Definition: rodbus.h:1202
void(* on_complete)(rodbus_nothing_t, void *)
Invoked when the asynchronous operation completes successfully.
Definition: rodbus.h:1197
Interface used to handle write requests received from the client.
Definition: rodbus.h:1534
rodbus_write_result_t(* write_single_coil)(uint16_t, bool, rodbus_database_t *, void *)
Write a single coil received from the client.
Definition: rodbus.h:1542
void * ctx
Context data.
Definition: rodbus.h:1571
rodbus_write_result_t(* write_multiple_registers)(uint16_t, rodbus_register_value_iterator_t *, rodbus_database_t *, void *)
Write multiple registers received from the client.
Definition: rodbus.h:1566
rodbus_write_result_t(* write_multiple_coils)(uint16_t, rodbus_bit_value_iterator_t *, rodbus_database_t *, void *)
Write multiple coils received from the client.
Definition: rodbus.h:1558
rodbus_write_result_t(* write_single_register)(uint16_t, uint16_t, rodbus_database_t *, void *)
write a single register received from the client
Definition: rodbus.h:1550
void(* on_destroy)(void *arg)
Callback when the underlying owner doesn't need the interface anymore.
Definition: rodbus.h:1569
Describes to the server if a write operation was successful or not.
Definition: rodbus.h:1468
uint8_t raw_exception
Raw exception value when rodbus_write_result_t::exception field is RODBUS_MODBUS_EXCEPTION_UNKNOWN.
Definition: rodbus.h:1474
rodbus_modbus_exception_t exception
Exception enumeration. If RODBUS_MODBUS_EXCEPTION_UNKNOWN, look at the raw value.
Definition: rodbus.h:1472
bool success
true if the operation was successful, false otherwise. Error details found in the exception field.
Definition: rodbus.h:1470