fix cpp compilation issues

This commit is contained in:
aleks
2025-02-05 12:02:04 +01:00
parent 5c0d66a8c0
commit a2a16545fc
2 changed files with 12 additions and 17 deletions

View File

@@ -5,6 +5,7 @@
*/
#pragma once
#include <inttypes.h>
#include "driver/uart.h" // for UART types
#include "sdkconfig.h"
@@ -13,20 +14,12 @@
#include "mb_endianness_utils.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "port_common.h"
#if __has_include("esp_check.h")
#include "esp_check.h"
#include "esp_log.h"
#include <inttypes.h>
#include "mb_port_types.h"
#define MB_RETURN_ON_FALSE(a, err_code, tag, format, ...) ESP_RETURN_ON_FALSE(a, err_code, tag, format __VA_OPT__(,) __VA_ARGS__)
#else
@@ -42,6 +35,10 @@ extern "C" {
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define MB_SLAVE_ADDR_PLACEHOLDER (0xFF)
#define MB_CONTROLLER_STACK_SIZE (CONFIG_FMB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
#define MB_CONTROLLER_PRIORITY (CONFIG_FMB_PORT_TASK_PRIO - 1) // priority of MB controller task

View File

@@ -9,19 +9,18 @@
#include "mb_config.h"
#include "mb_types.h"
#define MB_ATTR_WEAK __attribute__ ((weak))
#ifdef __cplusplus
extern "C" {
#endif
#define MB_ATTR_WEAK __attribute__ ((weak))
typedef enum _mb_comm_mode mb_mode_type_t;
#if (CONFIG_FMB_COMM_MODE_ASCII_EN || CONFIG_FMB_COMM_MODE_RTU_EN)
#include "driver/uart.h"
__attribute__((__packed__))
struct _port_serial_opts {
mb_mode_type_t mode; /*!< Modbus communication mode */
uart_port_t port; /*!< Modbus communication port (UART) number */
@@ -32,7 +31,7 @@ struct _port_serial_opts {
uart_word_length_t data_bits; /*!< Modbus number of data bits */
uart_stop_bits_t stop_bits; /*!< Modbus number of stop bits */
uart_parity_t parity; /*!< Modbus UART parity settings */
};
} __attribute__((__packed__));
typedef struct _port_serial_opts mb_serial_opts_t;
@@ -44,16 +43,15 @@ typedef enum _addr_type_enum {
MB_IPV6 = 2 /*!< TCP IPV6 addressing */
} mb_addr_type_t;
__attribute__((__packed__))
struct _port_common_opts {
mb_mode_type_t mode; /*!< Modbus communication mode */
uint16_t port; /*!< Modbus communication port (UART) number */
uint8_t uid; /*!< Modbus slave address field (dummy for master) */
uint32_t response_tout_ms; /*!< Modbus slave response timeout */
uint64_t test_tout_us; /*!< Modbus test timeout (reserved) */
};
} __attribute__((__packed__));
__attribute__((__packed__))
struct _port_tcp_opts {
mb_mode_type_t mode; /*!< Modbus communication mode */
uint16_t port; /*!< Modbus communication port (UART) number */
@@ -65,7 +63,7 @@ struct _port_tcp_opts {
void *ip_netif_ptr; /*!< Modbus network interface */
char *dns_name; /*!< Modbus node DNS name */
bool start_disconnected; /*!< (Master only option) do not wait for connection to all nodes before polling */
};
} __attribute__((__packed__));
typedef struct _port_tcp_opts mb_tcp_opts_t;
@@ -100,7 +98,7 @@ typedef struct _uid_info {
uint16_t uid; /*!< node unit ID (UID) field for MBAP frame */
uint16_t port; /*!< node port number */
mb_comm_mode_t proto; /*!< protocol type */
_Atomic mb_sock_state_t state; /*!< node state */
atomic_int state; /*!< node state */
void *inst; /*!< pointer to linked instance */
} mb_uid_info_t;