更新:多连接成功。modbus_tcp bug修复

This commit is contained in:
吴俊潮 2025-04-25 13:18:59 +08:00
parent bcd04aa1b5
commit e4414a8809
15 changed files with 16765 additions and 188436 deletions

View File

@ -2,6 +2,7 @@
#include "spi.h"
struct ch395q_t g_ch395q_sta;
uint8_t open_flag[8] = {0};
/**
* @brief ch395_gpio初始化
@ -414,6 +415,17 @@ void ch395_socket_interrupt(uint8_t sockindex)
if (sock_int_socket & SINT_STAT_CONNECT) /* 连接中断仅在TCP模式下有效 */
{
if( (sockindex > 0)&&(sockindex < 7) )
{
ch395_close_socket(sockindex + 1);
open_flag[sockindex + 1] = 0;
}else if(sockindex == 7)
{
ch395_close_socket(1);
open_flag[1] = 0;
}
if (g_ch395q_sta.socket[sockindex].config.proto == CH395Q_SOCKET_TCP_CLIENT)
{
ch395_set_keeplive(sockindex,1); /* 打开KEEPALIVE保活定时器 */
@ -549,7 +561,7 @@ void ch395_interrupt_handler(void)
* @retval
*/
int reconnect_times = 0;
uint8_t tcp_breath_cnt = 0,connect_cnt = 0;;
uint8_t tcp_breath_cnt = 0;
void ch395q_handler(void)
{
if(breathe_flag == 1)
@ -557,7 +569,6 @@ void ch395q_handler(void)
breathe_flag = 0;
tcp_breath_cnt++;
connect_cnt++;
if(tcp_breath_cnt > 60)
{
tcp_breath_cnt = 0;
@ -566,16 +577,9 @@ void ch395q_handler(void)
if (ch395_int_pin_wire == 0)
{
connect_cnt = 0;
ch395_interrupt_handler(); /* 中断处理函数 */
tcp_breath_cnt = 0;
}
if(connect_cnt == 10)
{
//ch395_tcp_disconnect(0);
}
else if(connect_cnt > 10)
connect_cnt = 11;
if(reconnect_flag == 1)
{
@ -593,19 +597,17 @@ void ch395q_handler(void)
//socket_watch[1]:0x01->listen, 0x04->established
uint8_t socket_watch[8][2];
uint8_t rec_test_flag = 0;
uint8_t open_flag[8] = {0};
uint8_t listen_flag = 0;
void ch395_reconnection(void)
{
//手动重置
if(rec_test_flag == 1)
{
rec_test_flag = 0;
ch395_close_socket(1);
}
for (uint8_t socket_index = CH395Q_SOCKET_0 ; socket_index <= CH395Q_SOCKET_7 ; socket_index ++ )
{
/* 检查sokect是否打开成功 */
//服务器端网线是否连接
if (g_ch395q_sta.phy_status == PHY_DISCONN && (g_ch395q_sta.dhcp_status == DHCP_UP || g_ch395q_sta.dhcp_status == DHCP_DOWN || g_ch395q_sta.dhcp_status == DHCP_STA))
{
reconnect_times++;
@ -620,7 +622,10 @@ void ch395_reconnection(void)
}
else
{
#if MULTI_CONNECT_ENABLE
//读取各个socket状态
ch395_cmd_get_socket_status(socket_index, socket_watch[socket_index]);
if(socket_index == CH395Q_SOCKET_0)
@ -632,11 +637,16 @@ void ch395_reconnection(void)
}else if(socket_watch[socket_index][1] != 0x01)
{
listen_flag = ch395_tcp_listen(socket_index);
ch395_tcp_listen(socket_index);
}
}
else
{
//socket 1-7
if( socket_watch[socket_index][0] == 0x05 )
{
open_flag[socket_index] = CH395_ERR_OPEN;
}
}
#else
ch395_cmd_get_socket_status(socket_index, socket_watch[socket_index]);
@ -737,8 +747,8 @@ uint16_t ch395_port = 8080;
//uint8_t ch395_macaddr[6] = {0x5C,0x53,0x10,0x6C,0x18,0x49};
/* 远程IP地址设置 */
//uint8_t ch395_des_ipaddr[4] = {192,168,1,111};
static uint8_t socket0_send_buf[255];
static uint8_t socket0_recv_buf[8][1024];
static uint8_t socket_send_buf[8][255];
static uint8_t socket_recv_buf[8][1024];
//static uint8_t socket0_recv_buf[1024];
ch395_socket cha95_sockct_sta[8];
@ -772,10 +782,10 @@ void ch395_init(void)
//memcpy(cha95_sockct_sta[0].net_config.macaddr, ch395_macaddr, sizeof(cha95_sockct_sta[0].net_config.macaddr)); /* 设置静态MAC地址 */
cha95_sockct_sta[0].sour_port = ch395_port; /* 源端口 */
cha95_sockct_sta[0].proto = CH395Q_SOCKET_TCP_SERVER; /* 设置协议 */
cha95_sockct_sta[0].send.buf = socket0_send_buf; /* 发送数据 */
cha95_sockct_sta[0].send.size = sizeof(socket0_send_buf); /* 发送数据大小 */
cha95_sockct_sta[0].recv.buf = socket0_recv_buf[0]; /* 接收数据缓冲区 */
cha95_sockct_sta[0].recv.size = sizeof(socket0_recv_buf[0]); /* 接收数据大小 */
cha95_sockct_sta[0].send.buf = socket_send_buf[0]; /* 发送数据 */
cha95_sockct_sta[0].send.size = sizeof(socket_send_buf[0]); /* 发送数据大小 */
cha95_sockct_sta[0].recv.buf = socket_recv_buf[0]; /* 接收数据缓冲区 */
cha95_sockct_sta[0].recv.size = sizeof(socket_recv_buf[0]); /* 接收数据大小 */
ch395q_socket_config(&cha95_sockct_sta[0]);
#if MULTI_CONNECT_ENABLE
@ -784,12 +794,14 @@ void ch395_init(void)
{
ch395_set_socket_prot_type(i, PROTO_TYPE_TCP);
ch395_set_socket_sourport(i, ch395_port);
cha95_sockct_sta[i].sour_port = ch395_port; /* 源端口 */
cha95_sockct_sta[i].proto = CH395Q_SOCKET_TCP_SERVER;
// cha95_sockct_sta[i].sour_port = ch395_port; /* 源端口 */
// cha95_sockct_sta[i].proto = CH395Q_SOCKET_TCP_SERVER;
cha95_sockct_sta[i].socket_enable = CH395Q_ENABLE;
cha95_sockct_sta[i].socket_index = i;
cha95_sockct_sta[i].recv.buf = socket0_recv_buf[i];
cha95_sockct_sta[i].recv.size = sizeof(socket0_recv_buf[i]);
cha95_sockct_sta[i].send.buf = socket_send_buf[i]; /* 发送数据 */
cha95_sockct_sta[i].send.size = sizeof(socket_send_buf[i]);
cha95_sockct_sta[i].recv.buf = socket_recv_buf[i];
cha95_sockct_sta[i].recv.size = sizeof(socket_recv_buf[i]);
//ch395q_socket_config(&cha95_sockct_sta[i]);
memcpy(&g_ch395q_sta.socket[i].config, &cha95_sockct_sta[i], sizeof(ch395_socket));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -148,24 +148,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>276</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134253914</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\modbus\Src\modbus_tcp.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\VOQC\../modbus/Src/modbus_tcp.c\276</Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -255,32 +238,12 @@
<Ww>
<count>17</count>
<WinNumber>1</WinNumber>
<ItemText>listen_flag</ItemText>
<ItemText>tcp_breath_cnt</ItemText>
</Ww>
<Ww>
<count>18</count>
<WinNumber>1</WinNumber>
<ItemText>tcp_breath_cnt</ItemText>
</Ww>
<Ww>
<count>19</count>
<WinNumber>1</WinNumber>
<ItemText>g_ch395q_sta,0x0A</ItemText>
</Ww>
<Ww>
<count>20</count>
<WinNumber>1</WinNumber>
<ItemText>connect_cnt</ItemText>
</Ww>
<Ww>
<count>21</count>
<WinNumber>1</WinNumber>
<ItemText>sock_int_socket</ItemText>
</Ww>
<Ww>
<count>22</count>
<WinNumber>1</WinNumber>
<ItemText>g_ch395q_sta</ItemText>
<ItemText>multi_connect_socket_index,0x0A</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>

Binary file not shown.

View File

@ -27,39 +27,9 @@ Project File Date: 04/09/2025
<h2>Output:</h2>
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Users\admin\Desktop\wujunchao\99_General softwares\Keil_v5\ARM\ARM Compiler_5_06\Bin'
Build target 'VOQC'
compiling main.c...
compiling gpio.c...
compiling adc.c...
compiling dma.c...
compiling i2c.c...
compiling spi.c...
compiling tim.c...
compiling usart.c...
compiling stm32f4xx_it.c...
compiling stm32f4xx_hal_msp.c...
compiling ads1256.c...
compiling ads1220.c...
compiling dac7311.c...
compiling eeprom.c...
compiling ms5803.c...
compiling ds18b20.c...
compiling hc595.c...
compiling hc165.c...
compiling mf5803.c...
compiling ch395.c...
compiling ch395cmd.c...
compiling modbus.c...
compiling modbus_rtu.c...
compiling modbus_tcp.c...
compiling adcs.c...
compiling gpios.c...
compiling timer.c...
compiling uarts.c...
compiling provalctrl.c...
compiling encoder.c...
compiling flash.c...
linking...
Program Size: Code=41998 RO-data=514 RW-data=568 ZI-data=16496
Program Size: Code=41838 RO-data=514 RW-data=568 ZI-data=18280
FromELF: creating hex file...
"VOQC\VOQC.axf" - 0 Error(s), 0 Warning(s).
@ -84,7 +54,7 @@ Package Vendor: Keil
<h2>Collection of Component Files used:</h2>
* Component: ARM::CMSIS:CORE@5.6.0
Build Time Elapsed: 00:01:57
Build Time Elapsed: 00:00:06
</pre>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
<title>Static Call Graph - [VOQC\VOQC.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image VOQC\VOQC.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060960: Last Updated: Thu Apr 24 18:05:07 2025
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060960: Last Updated: Fri Apr 25 11:06:12 2025
<BR><P>
<H3>Maximum Stack Usage = 2392 bytes + Unknown(Functions without stacksize, Cycles, Untraceable Function Pointers)</H3><H3>
Call chain for Maximum Stack Depth:</H3>
@ -586,7 +586,6 @@ Global Symbols
<LI><a href="#[186]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;writemultireg_tcp
<LI><a href="#[185]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;writemulticoil_tcp
<LI><a href="#[183]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;readinputreg_tcp
<LI><a href="#[182]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;readholdreg_tcp
<LI><a href="#[181]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;readdisinputstate_tcp
<LI><a href="#[180]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;readcoilstate_tcp
<LI><a href="#[188]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_errfunction_tcp
@ -1844,10 +1843,10 @@ Global Symbols
</UL>
<BR>[Calls]<UL><LI><a href="#[114]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ads1256_init
<LI><a href="#[91]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ADS1256ReadData
<LI><a href="#[113]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dsub
<LI><a href="#[99]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dmul
<LI><a href="#[10d]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2uiz
<LI><a href="#[10a]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ddiv
<LI><a href="#[113]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dsub
</UL>
<BR>[Called By]<UL><LI><a href="#[11a]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;analog_gather
</UL>
@ -1955,6 +1954,7 @@ Global Symbols
<LI><a href="#[11f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_write_cmd
</UL>
<BR>[Called By]<UL><LI><a href="#[18f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;set_ipv4
<LI><a href="#[13c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_socket_interrupt
<LI><a href="#[68]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_reconnection
</UL>
@ -2178,7 +2178,7 @@ Global Symbols
<LI><a href="#[68]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_reconnection
</UL>
<P><STRONG><a name="[137]"></a>ch395_init</STRONG> (Thumb, 266 bytes, Stack size 8 bytes, ch395.o(i.ch395_init))
<P><STRONG><a name="[137]"></a>ch395_init</STRONG> (Thumb, 272 bytes, Stack size 8 bytes, ch395.o(i.ch395_init))
<BR><BR>[Stack]<UL><LI>Max Depth = 208 + Unknown Stack Size
<LI>Call Chain = ch395_init &rArr; ch395q_socket_config &rArr; ch395_tcp_listen &rArr; ch395_get_cmd_status &rArr; ch395_write_cmd &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
@ -2289,7 +2289,7 @@ Global Symbols
<LI><a href="#[123]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_read_data
</UL>
<P><STRONG><a name="[68]"></a>ch395_reconnection</STRONG> (Thumb, 272 bytes, Stack size 16 bytes, ch395.o(i.ch395_reconnection))
<P><STRONG><a name="[68]"></a>ch395_reconnection</STRONG> (Thumb, 282 bytes, Stack size 16 bytes, ch395.o(i.ch395_reconnection))
<BR><BR>[Stack]<UL><LI>Max Depth = 224 + Unknown Stack Size
<LI>Call Chain = ch395_reconnection &rArr; ch395_init &rArr; ch395q_socket_config &rArr; ch395_tcp_listen &rArr; ch395_get_cmd_status &rArr; ch395_write_cmd &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
@ -2417,7 +2417,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[13c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_socket_interrupt
</UL>
<P><STRONG><a name="[13c]"></a>ch395_socket_interrupt</STRONG> (Thumb, 390 bytes, Stack size 24 bytes, ch395.o(i.ch395_socket_interrupt))
<P><STRONG><a name="[13c]"></a>ch395_socket_interrupt</STRONG> (Thumb, 432 bytes, Stack size 24 bytes, ch395.o(i.ch395_socket_interrupt))
<BR><BR>[Stack]<UL><LI>Max Depth = 2368<LI>Call Chain = ch395_socket_interrupt &rArr; modbus_process_tcp &rArr; modbus_analysis_tcp &rArr; writemulticoil_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[ad]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;HAL_Delay
@ -2430,6 +2430,7 @@ Global Symbols
<LI><a href="#[131]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_get_socket_int
<LI><a href="#[130]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_get_recv_length
<LI><a href="#[12f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_get_recv_data
<LI><a href="#[11e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_close_socket
</UL>
<BR>[Called By]<UL><LI><a href="#[13b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_interrupt_handler
</UL>
@ -2548,7 +2549,7 @@ Global Symbols
<LI><a href="#[11e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_close_socket
</UL>
<P><STRONG><a name="[14e]"></a>ch395q_handler</STRONG> (Thumb, 124 bytes, Stack size 8 bytes, ch395.o(i.ch395q_handler))
<P><STRONG><a name="[14e]"></a>ch395q_handler</STRONG> (Thumb, 84 bytes, Stack size 8 bytes, ch395.o(i.ch395q_handler))
<BR><BR>[Stack]<UL><LI>Max Depth = 2384<LI>Call Chain = ch395q_handler &rArr; ch395_interrupt_handler &rArr; ch395_socket_interrupt &rArr; modbus_process_tcp &rArr; modbus_analysis_tcp &rArr; writemulticoil_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[13b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_interrupt_handler
@ -3027,7 +3028,7 @@ Global Symbols
<LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[188]"></a>modbus_errfunction_tcp</STRONG> (Thumb, 220 bytes, Stack size 1040 bytes, modbus_tcp.o(i.modbus_errfunction_tcp))
<P><STRONG><a name="[188]"></a>modbus_errfunction_tcp</STRONG> (Thumb, 206 bytes, Stack size 1040 bytes, modbus_tcp.o(i.modbus_errfunction_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 1224<LI>Call Chain = modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3100,7 +3101,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[180]"></a>readcoilstate_tcp</STRONG> (Thumb, 458 bytes, Stack size 1072 bytes, modbus_tcp.o(i.readcoilstate_tcp))
<P><STRONG><a name="[180]"></a>readcoilstate_tcp</STRONG> (Thumb, 444 bytes, Stack size 1072 bytes, modbus_tcp.o(i.readcoilstate_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2296<LI>Call Chain = readcoilstate_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3124,7 +3125,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[181]"></a>readdisinputstate_tcp</STRONG> (Thumb, 450 bytes, Stack size 1072 bytes, modbus_tcp.o(i.readdisinputstate_tcp))
<P><STRONG><a name="[181]"></a>readdisinputstate_tcp</STRONG> (Thumb, 436 bytes, Stack size 1072 bytes, modbus_tcp.o(i.readdisinputstate_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2296<LI>Call Chain = readdisinputstate_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3147,11 +3148,10 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[182]"></a>readholdreg_tcp</STRONG> (Thumb, 392 bytes, Stack size 1064 bytes, modbus_tcp.o(i.readholdreg_tcp))
<P><STRONG><a name="[182]"></a>readholdreg_tcp</STRONG> (Thumb, 340 bytes, Stack size 1064 bytes, modbus_tcp.o(i.readholdreg_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2288<LI>Call Chain = readholdreg_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
<LI><a href="#[169]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_memcpy
<LI><a href="#[188]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_errfunction_tcp
<LI><a href="#[18d]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;GetHoldRegData
</UL>
@ -3170,7 +3170,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[183]"></a>readinputreg_tcp</STRONG> (Thumb, 386 bytes, Stack size 1064 bytes, modbus_tcp.o(i.readinputreg_tcp))
<P><STRONG><a name="[183]"></a>readinputreg_tcp</STRONG> (Thumb, 372 bytes, Stack size 1064 bytes, modbus_tcp.o(i.readinputreg_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2288<LI>Call Chain = readinputreg_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3280,7 +3280,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[185]"></a>writemulticoil_tcp</STRONG> (Thumb, 474 bytes, Stack size 1080 bytes, modbus_tcp.o(i.writemulticoil_tcp))
<P><STRONG><a name="[185]"></a>writemulticoil_tcp</STRONG> (Thumb, 460 bytes, Stack size 1080 bytes, modbus_tcp.o(i.writemulticoil_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2304<LI>Call Chain = writemulticoil_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3303,7 +3303,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[186]"></a>writemultireg_tcp</STRONG> (Thumb, 386 bytes, Stack size 1064 bytes, modbus_tcp.o(i.writemultireg_tcp))
<P><STRONG><a name="[186]"></a>writemultireg_tcp</STRONG> (Thumb, 372 bytes, Stack size 1064 bytes, modbus_tcp.o(i.writemultireg_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2288<LI>Call Chain = writemultireg_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3326,7 +3326,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[187]"></a>writesinglecoil_tcp</STRONG> (Thumb, 314 bytes, Stack size 1056 bytes, modbus_tcp.o(i.writesinglecoil_tcp))
<P><STRONG><a name="[187]"></a>writesinglecoil_tcp</STRONG> (Thumb, 300 bytes, Stack size 1056 bytes, modbus_tcp.o(i.writesinglecoil_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2280<LI>Call Chain = writesinglecoil_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data
@ -3349,7 +3349,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[175]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;modbus_analysis_rtu
</UL>
<P><STRONG><a name="[184]"></a>writesinglereg_tcp</STRONG> (Thumb, 300 bytes, Stack size 1056 bytes, modbus_tcp.o(i.writesinglereg_tcp))
<P><STRONG><a name="[184]"></a>writesinglereg_tcp</STRONG> (Thumb, 286 bytes, Stack size 1056 bytes, modbus_tcp.o(i.writesinglereg_tcp))
<BR><BR>[Stack]<UL><LI>Max Depth = 2280<LI>Call Chain = writesinglereg_tcp &rArr; modbus_errfunction_tcp &rArr; ch395_send_data &rArr; ch395_write_data &rArr; ch395_read_write_byte &rArr; spi2_read_write_byte &rArr; HAL_SPI_TransmitReceive &rArr; SPI_EndRxTxTransaction &rArr; SPI_WaitFlagStateUntilTimeout
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ch395_send_data

File diff suppressed because it is too large Load Diff

View File

@ -1789,7 +1789,7 @@ I (../CH395Q/ch395inc.h)(0x6800CA4E)
I (../Core/Inc/spi.h)(0x668F85FC)
I (../CH395Q/ch395cmd.h)(0x664FF969)
I (../board/Inc/ms5803.h)(0x669760FF)
F (..\CH395Q\ch395.c)(0x680A0C4F)(--c99 -c --cpu Cortex-M4.fp.sp -g -O0 -Otime --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../board/Inc -I ../CH395Q -I ../modbus/Inc -I ../users/Inc -I.\RTE\_VOQC -IC:\Users\admin\AppData\Local\Arm\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include -IC:\Users\admin\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION="539" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o voqc\ch395.o --omf_browse voqc\ch395.crf --depend voqc\ch395.d)
F (..\CH395Q\ch395.c)(0x680AFC18)(--c99 -c --cpu Cortex-M4.fp.sp -g -O0 -Otime --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../board/Inc -I ../CH395Q -I ../modbus/Inc -I ../users/Inc -I.\RTE\_VOQC -IC:\Users\admin\AppData\Local\Arm\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include -IC:\Users\admin\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION="539" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o voqc\ch395.o --omf_browse voqc\ch395.crf --depend voqc\ch395.d)
I (..\CH395Q\ch395.h)(0x6809FC28)
I (..\CH395Q\ch395inc.h)(0x6800CA4E)
I (../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h)(0x66B41EAC)
@ -1987,7 +1987,7 @@ I (../CH395Q/ch395inc.h)(0x6800CA4E)
I (../Core/Inc/spi.h)(0x668F85FC)
I (../CH395Q/ch395cmd.h)(0x664FF969)
I (C:\Users\admin\Desktop\wujunchao\99_General softwares\Keil_v5\ARM\ARM Compiler_5_06\include\string.h)(0x5E8E3CC2)
F (..\modbus\Src\modbus_tcp.c)(0x680A0C04)(--c99 -c --cpu Cortex-M4.fp.sp -g -O0 -Otime --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../board/Inc -I ../CH395Q -I ../modbus/Inc -I ../users/Inc -I.\RTE\_VOQC -IC:\Users\admin\AppData\Local\Arm\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include -IC:\Users\admin\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION="539" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o voqc\modbus_tcp.o --omf_browse voqc\modbus_tcp.crf --depend voqc\modbus_tcp.d)
F (..\modbus\Src\modbus_tcp.c)(0x680AF7A1)(--c99 -c --cpu Cortex-M4.fp.sp -g -O0 -Otime --apcs=interwork --split_sections -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../board/Inc -I ../CH395Q -I ../modbus/Inc -I ../users/Inc -I.\RTE\_VOQC -IC:\Users\admin\AppData\Local\Arm\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include -IC:\Users\admin\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION="539" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o voqc\modbus_tcp.o --omf_browse voqc\modbus_tcp.crf --depend voqc\modbus_tcp.d)
I (../modbus/Inc/modbus.h)(0x680A0BF4)
I (../users/Inc/timer.h)(0x68098C0E)
I (../Core/Inc/tim.h)(0x6694D67D)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -71,7 +71,7 @@ void readcoilstate_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -149,7 +149,7 @@ void readdisinputstate_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -174,6 +174,7 @@ void readdisinputstate_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
*:[][03][][][][][CRC低][CRC高]
*:[][03][][0][0][1][1][n高][n低][CRC低][CRC高]
*******************************************************************************/
//uint8_t buf_watch[30] = {0};
void readholdreg_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
{
uint16_t wRegStartAdd, wRegLen, i, wRegValue;
@ -209,8 +210,10 @@ void readholdreg_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
}
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
// memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
// memcpy(buf_watch, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
//ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
return;
}
@ -271,7 +274,7 @@ void readinputreg_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -324,7 +327,7 @@ void writesinglereg_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
else
@ -377,7 +380,7 @@ void writemultireg_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -428,7 +431,7 @@ void writesinglecoil_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -506,7 +509,7 @@ void writemulticoil_tcp(uint8_t * upRxdbuf, uint16_t wRxdLen)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
return;
}
@ -547,7 +550,7 @@ void modbus_errfunction_tcp(uint8_t uCmdCode, uint8_t uErrorCode)
MODBUS_TCP.send.size = (uCommIndexNum <= 255 ? uCommIndexNum : 255);
memcpy(MODBUS_TCP.send.buf, upTxdbuf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, MODBUS_TCP.send.buf, MODBUS_TCP.send.size);
ch395_send_data(MODBUS_SOCKET, upTxdbuf, MODBUS_TCP.send.size);
}
/*******************************************************************************