![]() |
GaIA BIOS Library
|
Modbus/TCP slave function definitions. More...
#include <stdbool.h>#include <stdint.h>#include <modbus_core/modbus.h>#include <modbus_core/modbus_exceptions.h>#include <modbus_core/modbus_types.h>#include <modbus_core/modbus_rtos.h>#include <modbus_tcp/modbus_tcp.h>Data Structures | |
| struct | mb_tcp_config_t |
| This structure represents the configuration of a Modbus/TCP slave. More... | |
Typedefs | |
| typedef struct mb_tcp_transactions_queue | mb_tcp_transactions_queue_t |
| This structure represents a queue of transactions. | |
Functions | |
| void | mb_tcp_set_secure_addrs (const ip_addr_t *auth_addrs, uint8_t auth_addrs_count, mb_tcp_config_t *conf) |
| Sets the secure addresses for a modbus node. | |
| void | mb_tcp_set_priority_conns (ip_addr_t *priority_conn_addrs, uint8_t priority_conn_addrs_count, mb_tcp_config_t *conf) |
| Sets the addresses for the priority connection pool. | |
| mb_tcp_config_t * | mb_tcp_init (uint8_t jbus, mb_data_handlers_t *handlers, uint16_t port, uint8_t socket_count, uint16_t keep_alive, uint8_t trans_count, uint8_t non_priority_conns_max) |
| Initializes a modbus node. | |
| void | mb_tcp_close (mb_tcp_config_t *conf) |
| Releases all the connections of the node. | |
| uint8_t | mb_tcp_slave_loop (mb_tcp_config_t *conf, uint32_t timeout) |
| Function that processes modbus requests. | |
Modbus/TCP slave function definitions.
| void mb_tcp_close | ( | mb_tcp_config_t * | conf | ) |
Releases all the connections of the node.
The configuration structure is deallocated.
| conf | configuration structure of the modbus node to close. |
| mb_tcp_config_t * mb_tcp_init | ( | uint8_t | jbus, |
| mb_data_handlers_t * | handlers, | ||
| uint16_t | port, | ||
| uint8_t | socket_count, | ||
| uint16_t | keep_alive, | ||
| uint8_t | trans_count, | ||
| uint8_t | non_priority_conns_max ) |
Initializes a modbus node.
| jbus | 0 if the jbus mode is disabled. |
| handlers | pointer to the data handlers structure containing the function pointers to use to process modbus requests. |
| port | TCP port to listen on. |
| socket_count | number of socket to use for listening for incoming connections. |
| keep_alive | TCP keep alive for the established connections. |
| trans_count | maximum number of transactions to process simultaneously. |
| non_priority_conns_max | maximum number of connections of the non-priority pool. |
| void mb_tcp_set_priority_conns | ( | ip_addr_t * | priority_conn_addrs, |
| uint8_t | priority_conn_addrs_count, | ||
| mb_tcp_config_t * | conf ) |
Sets the addresses for the priority connection pool.
Connections from these addresses will not be rejected if they are authorized addresses.
| priority_conn_addrs | array of ip addresses. |
| priority_conn_addrs_count | number of elements of the specified array. |
| conf | configuration of the modbus node. |
| void mb_tcp_set_secure_addrs | ( | const ip_addr_t * | auth_addrs, |
| uint8_t | auth_addrs_count, | ||
| mb_tcp_config_t * | conf ) |
Sets the secure addresses for a modbus node.
| auth_addrs | array of IP addresses that are secure. |
| auth_addrs_count | number of IP addresses that are secure. |
| conf | configuration of the modbus node. |
| uint8_t mb_tcp_slave_loop | ( | mb_tcp_config_t * | conf, |
| uint32_t | timeout ) |
Function that processes modbus requests.
It has to be invoked in a loop.
| conf | configuration of the node. |
| timeout | time to wait for incoming requests to process. |
MSG_RECEIVED if a request has been processed, MSG_TIMEOUT otherwise.