Skip to content

Commit c2e915b

Browse files
committed
feat(modbus): modify modbus tcp port that can run on ESP8266
1 parent c758052 commit c2e915b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+204
-3749
lines changed

components/freemodbus/CMakeLists.txt

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,13 @@ set(srcs
55
"common/esp_modbus_slave.c"
66
"modbus/mb.c"
77
"modbus/mb_m.c"
8-
"modbus/ascii/mbascii.c"
9-
"modbus/ascii/mbascii_m.c"
10-
"modbus/rtu/mbrtu_m.c"
11-
"modbus/rtu/mbrtu.c"
12-
"modbus/rtu/mbcrc.c"
138
"modbus/tcp/mbtcp.c"
149
"modbus/tcp/mbtcp_m.c"
1510
"port/port.c"
1611
"port/portevent.c"
1712
"port/portevent_m.c"
1813
"port/portother.c"
1914
"port/portother_m.c"
20-
"port/portserial.c"
21-
"port/portserial_m.c"
2215
"port/porttimer.c"
2316
"port/porttimer_m.c"
2417
"modbus/functions/mbfunccoils.c"
@@ -32,28 +25,21 @@ set(srcs
3225
"modbus/functions/mbfuncinput_m.c"
3326
"modbus/functions/mbfuncother.c"
3427
"modbus/functions/mbutils.c"
35-
"serial_slave/modbus_controller/mbc_serial_slave.c"
36-
"serial_master/modbus_controller/mbc_serial_master.c"
3728
"tcp_slave/port/port_tcp_slave.c"
3829
"tcp_slave/modbus_controller/mbc_tcp_slave.c"
3930
"tcp_master/modbus_controller/mbc_tcp_master.c"
4031
"tcp_master/port/port_tcp_master.c"
4132
"common/esp_modbus_master_tcp.c"
42-
"common/esp_modbus_slave_tcp.c"
43-
"common/esp_modbus_master_serial.c"
44-
"common/esp_modbus_slave_serial.c")
33+
"common/esp_modbus_slave_tcp.c")
4534

4635
set(include_dirs common/include)
4736

4837
set(priv_include_dirs common port modbus modbus/ascii modbus/functions
4938
modbus/rtu modbus/tcp modbus/include)
5039

51-
list(APPEND priv_include_dirs serial_slave/port serial_slave/modbus_controller
52-
serial_master/port serial_master/modbus_controller
53-
tcp_slave/port tcp_slave/modbus_controller
40+
list(APPEND priv_include_dirs tcp_slave/port tcp_slave/modbus_controller
5441
tcp_master/port tcp_master/modbus_controller)
5542

5643
idf_component_register(SRCS "${srcs}"
5744
INCLUDE_DIRS "${include_dirs}"
58-
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
59-
REQUIRES driver)
45+
PRIV_INCLUDE_DIRS "${priv_include_dirs}")

components/freemodbus/Kconfig

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ menu "Modbus configuration"
3535
Once expired the current connection with the client will be closed
3636
and Modbus slave will be waiting for new connection to accept.
3737

38-
config FMB_COMM_MODE_RTU_EN
39-
bool "Enable Modbus stack support for RTU mode"
40-
default y
41-
help
42-
Enable RTU Modbus communication mode option for Modbus serial stack.
43-
44-
config FMB_COMM_MODE_ASCII_EN
45-
bool "Enable Modbus stack support for ASCII mode"
46-
default y
47-
help
48-
Enable ASCII Modbus communication mode option for Modbus serial stack.
49-
5038
config FMB_MASTER_TIMEOUT_MS_RESPOND
5139
int "Slave respond timeout (Milliseconds)"
5240
default 150
@@ -88,23 +76,6 @@ menu "Modbus configuration"
8876
This buffer is used for modbus frame transfer. The Modbus protocol maximum
8977
frame size is 256 bytes. Bigger size can be used for non standard implementations.
9078

91-
config FMB_SERIAL_ASCII_BITS_PER_SYMB
92-
int "Number of data bits per ASCII character"
93-
default 8
94-
range 7 8
95-
depends on FMB_COMM_MODE_ASCII_EN
96-
help
97-
This option defines the number of data bits per ASCII character.
98-
99-
config FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS
100-
int "Response timeout for ASCII communication mode (ms)"
101-
default 1000
102-
range 300 2000
103-
depends on FMB_COMM_MODE_ASCII_EN
104-
help
105-
This option defines response timeout of slave in milliseconds for ASCII communication mode.
106-
Thus the timeout will expire and allow the master program to handle the error.
107-
10879
config FMB_PORT_TASK_PRIO
10980
int "Modbus port task priority"
11081
range 3 10
@@ -163,13 +134,6 @@ menu "Modbus configuration"
163134
Modbus stack event queue timeout in milliseconds. This may help to optimize
164135
Modbus stack event processing time.
165136

166-
config FMB_TIMER_PORT_ENABLED
167-
bool "Modbus slave stack use timer for 3.5T symbol time measurement"
168-
default y
169-
help
170-
If this option is set the Modbus stack uses timer for T3.5 time measurement.
171-
Else the internal UART TOUT timeout is used for 3.5T symbol time measurement.
172-
173137
config FMB_TIMER_GROUP
174138
int "Modbus Timer group number"
175139
range 0 1

components/freemodbus/common/esp_modbus_master_serial.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

components/freemodbus/common/esp_modbus_slave_serial.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

components/freemodbus/common/include/esp_modbus_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#ifndef _MB_IFACE_COMMON_H
1717
#define _MB_IFACE_COMMON_H
18-
18+
#include "freertos/FreeRTOS.h"
1919
#include "driver/uart.h" // for UART types
2020

2121
#ifdef __cplusplus

components/freemodbus/common/include/esp_modbus_master.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include <stdint.h> // for standard int types definition
2020
#include <stddef.h> // for NULL and std defines
21-
#include "soc/soc.h" // for BITN definitions
2221
#include "esp_modbus_common.h" // for common types
2322

2423
#ifdef __cplusplus

components/freemodbus/common/include/esp_modbus_slave.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// Public interface header for slave
2020
#include <stdint.h> // for standard int types definition
2121
#include <stddef.h> // for NULL and std defines
22-
#include "soc/soc.h" // for BITN definitions
2322
#include "freertos/FreeRTOS.h" // for task creation and queues access
2423
#include "freertos/event_groups.h" // for event groups
2524
#include "esp_modbus_common.h" // for common types

components/freemodbus/common/mbc_slave.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
#ifndef _MB_CONTROLLER_SLAVE_H
1616
#define _MB_CONTROLLER_SLAVE_H
17-
17+
#include "freertos/FreeRTOS.h"
1818
#include "driver/uart.h" // for uart defines
1919
#include "errno.h" // for errno
2020
#include "esp_log.h" // for log write

components/freemodbus/modbus/mb_m.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ eMBMasterPoll( void )
351351
if ( ( eStatus == MB_ENOERR ) && ( ( ucRcvAddress == ucMBMasterGetDestAddress() )
352352
|| ( ucRcvAddress == MB_TCP_PSEUDO_ADDRESS ) ) )
353353
{
354-
( void ) xMBMasterPortEventPost( EV_MASTER_EXECUTE );
355354
ESP_LOGD(MB_PORT_TAG, "%s: Packet data received successfully (%u).", __func__, eStatus);
356355
ESP_LOG_BUFFER_HEX_LEVEL("POLL receive buffer", (void*)ucMBFrame, (uint16_t)usLength, ESP_LOG_DEBUG);
357356
( void ) xMBMasterPortEventPost( EV_MASTER_EXECUTE );

components/freemodbus/port/port.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define PORT_COMMON_H_
1818

1919
#include "freertos/FreeRTOS.h"
20-
#include "freertos/xtensa_api.h"
2120
#include "esp_log.h" // for ESP_LOGE macro
2221
#include "mbconfig.h"
2322

components/freemodbus/port/portevent.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "mbport.h"
5353
#include "port.h"
5454
#include "sdkconfig.h"
55-
#include "port_serial_slave.h"
5655
/* ----------------------- Variables ----------------------------------------*/
5756
static xQueueHandle xQueueHdl;
5857

components/freemodbus/port/portevent_m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "port.h"
4545
#include "mbport.h"
4646
#include "freertos/semphr.h"
47-
#include "port_serial_master.h"
47+
4848

4949
#if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED || MB_MASTER_TCP_ENABLED
5050
/* ----------------------- Defines ------------------------------------------*/

0 commit comments

Comments
 (0)