Skip to content

Commit 94e9664

Browse files
committed
Merge branch 'bugfix/fix_serial_slave_delay_before_send' into 'master'
fix modbus slave wait before send option Closes IDFGH-11279 See merge request idf/esp-modbus!54
2 parents 64c5400 + e12c7ff commit 94e9664

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ menu "Modbus configuration"
104104
help
105105
This option defines the number of data bits per ASCII character.
106106

107+
config FMB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS
108+
int "Wait before send for ASCII communication mode (ms)"
109+
default 0
110+
range 0 1000
111+
depends on FMB_COMM_MODE_ASCII_EN
112+
help
113+
This option defines timeout before slave sends the response in ASCII communication mode.
114+
This allows to work with slow masters. Zero means delay before send is disabled.
115+
107116
config FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS
108117
int "Response timeout for ASCII communication mode (ms)"
109118
default 1000

freemodbus/modbus/include/mbconfig.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ PR_BEGIN_EXTERN_C
121121
* transmitting the frame. If the master is to slow with enabling its
122122
* receiver then he will not receive the response correctly.
123123
*/
124-
#ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS
124+
#ifndef CONFIG_FMB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS
125125
#define MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ( 0 )
126+
#else
127+
#define MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ( CONFIG_FMB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS )
126128
#endif
127129

128130
/*! \brief Maximum number of Modbus functions codes the protocol stack

freemodbus/port/porttimer.c

+5
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,8 @@ void vMBPortTimerClose(void)
125125
}
126126
#endif
127127
}
128+
129+
void vMBPortTimersDelay(USHORT usTimeOutMS)
130+
{
131+
vTaskDelay(usTimeOutMS / portTICK_PERIOD_MS);
132+
}

0 commit comments

Comments
 (0)