Skip to content

Commit ccddde0

Browse files
committed
fix cpp compilation issues
1 parent 5c0d66a commit ccddde0

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

modbus/mb_controller/common/include/esp_modbus_common.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#pragma once
8+
#include <inttypes.h>
89

910
#include "driver/uart.h" // for UART types
1011
#include "sdkconfig.h"
@@ -13,20 +14,12 @@
1314
#include "mb_endianness_utils.h"
1415
#endif
1516

16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2017
#include "port_common.h"
2118

2219
#if __has_include("esp_check.h")
2320
#include "esp_check.h"
2421
#include "esp_log.h"
2522

26-
#include <inttypes.h>
27-
28-
#include "mb_port_types.h"
29-
3023
#define MB_RETURN_ON_FALSE(a, err_code, tag, format, ...) ESP_RETURN_ON_FALSE(a, err_code, tag, format __VA_OPT__(,) __VA_ARGS__)
3124

3225
#else
@@ -42,6 +35,10 @@ extern "C" {
4235

4336
#endif
4437

38+
#ifdef __cplusplus
39+
extern "C" {
40+
#endif
41+
4542
#define MB_SLAVE_ADDR_PLACEHOLDER (0xFF)
4643
#define MB_CONTROLLER_STACK_SIZE (CONFIG_FMB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
4744
#define MB_CONTROLLER_PRIORITY (CONFIG_FMB_PORT_TASK_PRIO - 1) // priority of MB controller task

modbus/mb_objects/include/mb_port_types.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typedef enum _mb_comm_mode mb_mode_type_t;
2121

2222
#include "driver/uart.h"
2323

24-
__attribute__((__packed__))
2524
struct _port_serial_opts {
2625
mb_mode_type_t mode; /*!< Modbus communication mode */
2726
uart_port_t port; /*!< Modbus communication port (UART) number */
@@ -32,7 +31,7 @@ struct _port_serial_opts {
3231
uart_word_length_t data_bits; /*!< Modbus number of data bits */
3332
uart_stop_bits_t stop_bits; /*!< Modbus number of stop bits */
3433
uart_parity_t parity; /*!< Modbus UART parity settings */
35-
};
34+
} __attribute__((__packed__));
3635

3736
typedef struct _port_serial_opts mb_serial_opts_t;
3837

@@ -44,16 +43,15 @@ typedef enum _addr_type_enum {
4443
MB_IPV6 = 2 /*!< TCP IPV6 addressing */
4544
} mb_addr_type_t;
4645

47-
__attribute__((__packed__))
46+
4847
struct _port_common_opts {
4948
mb_mode_type_t mode; /*!< Modbus communication mode */
5049
uint16_t port; /*!< Modbus communication port (UART) number */
5150
uint8_t uid; /*!< Modbus slave address field (dummy for master) */
5251
uint32_t response_tout_ms; /*!< Modbus slave response timeout */
5352
uint64_t test_tout_us; /*!< Modbus test timeout (reserved) */
54-
};
53+
} __attribute__((__packed__));
5554

56-
__attribute__((__packed__))
5755
struct _port_tcp_opts {
5856
mb_mode_type_t mode; /*!< Modbus communication mode */
5957
uint16_t port; /*!< Modbus communication port (UART) number */
@@ -65,7 +63,7 @@ struct _port_tcp_opts {
6563
void *ip_netif_ptr; /*!< Modbus network interface */
6664
char *dns_name; /*!< Modbus node DNS name */
6765
bool start_disconnected; /*!< (Master only option) do not wait for connection to all nodes before polling */
68-
};
66+
} __attribute__((__packed__));
6967

7068
typedef struct _port_tcp_opts mb_tcp_opts_t;
7169

@@ -100,7 +98,7 @@ typedef struct _uid_info {
10098
uint16_t uid; /*!< node unit ID (UID) field for MBAP frame */
10199
uint16_t port; /*!< node port number */
102100
mb_comm_mode_t proto; /*!< protocol type */
103-
_Atomic mb_sock_state_t state; /*!< node state */
101+
atomic_int state; /*!< node state */
104102
void *inst; /*!< pointer to linked instance */
105103
} mb_uid_info_t;
106104

0 commit comments

Comments
 (0)