串口发送超时导致发送一帧数据时丢字节。增大超时时间
This commit is contained in:
parent
8b1ad41ad6
commit
f7b2b40310
|
@ -148,24 +148,7 @@
|
|||
<Name>-UB -O2254 -SF1800 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>117</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134252704</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\TEST2\../Core/Src/main.c\117</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
|
|
@ -33,7 +33,7 @@ static err_t tcpecho_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t
|
|||
#if 1
|
||||
memcpy(hart1_uart5.tx_data, (int *)p->payload, p->tot_len);
|
||||
HART1_RTS_SEND;
|
||||
HAL_UART_Transmit(&huart5, hart1_uart5.tx_data, p->tot_len, 100);
|
||||
HAL_UART_Transmit(&huart5, hart1_uart5.tx_data, p->tot_len, 1000);
|
||||
HART1_RTS_RECEIVE;
|
||||
#endif
|
||||
#if 0
|
||||
|
@ -158,126 +158,3 @@ void user_send_data_hart2(uint8_t *data, uint16_t len)
|
|||
tcp_write(server_pcb2, data, len, 1);
|
||||
}
|
||||
}
|
||||
// #include "lwip/tcp.h"
|
||||
// #include "lwip/pbuf.h"
|
||||
// #include "lwip/err.h"
|
||||
// #include "lwip/sys.h"
|
||||
// #include "stm32f4xx_hal.h" // 根据具体的 STM32 系列修改头文件
|
||||
|
||||
// // 定义多个端口号
|
||||
// #define PORT1 5000
|
||||
// #define PORT2 6000
|
||||
|
||||
// // 定义 TCP 连接状态
|
||||
// enum tcp_states {
|
||||
// TCP_STATE_CLOSED,
|
||||
// TCP_STATE_LISTEN,
|
||||
// TCP_STATE_CONNECTED
|
||||
// };
|
||||
|
||||
// // 定义 TCP 连接结构体
|
||||
// struct tcp_connection {
|
||||
// struct tcp_pcb *pcb;
|
||||
// enum tcp_states state;
|
||||
// };
|
||||
|
||||
// // TCP 接收回调函数
|
||||
// static err_t tcp_recv_callback(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) {
|
||||
// if (err == ERR_OK && p!= NULL) {
|
||||
// // 打印接收到的数据
|
||||
// for (u16_t i = 0; i < p->len; i++) {
|
||||
// printf("Received on TCP: %c", ((char *)p->payload)[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
// // 释放接收缓冲区
|
||||
// pbuf_free(p);
|
||||
// }
|
||||
// return ERR_OK;
|
||||
// }
|
||||
|
||||
// // TCP 错误回调函数
|
||||
// static void tcp_err_callback(void *arg, err_t err) {
|
||||
// struct tcp_connection *conn = (struct tcp_connection *)arg;
|
||||
// if (conn->pcb!= NULL) {
|
||||
// tcp_close(conn->pcb);
|
||||
// mem_free(conn);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // TCP 连接回调函数
|
||||
// static err_t tcp_accept_callback(void *arg, struct tcp_pcb *pcb, err_t err) {
|
||||
// struct tcp_connection *conn = (struct tcp_connection *)mem_malloc(sizeof(struct tcp_connection));
|
||||
// if (conn == NULL) {
|
||||
// tcp_close(pcb);
|
||||
// return ERR_MEM;
|
||||
// }
|
||||
// conn->pcb = pcb;
|
||||
// conn->state = TCP_STATE_CONNECTED;
|
||||
// tcp_arg(pcb, conn);
|
||||
// tcp_recv(pcb, tcp_recv_callback);
|
||||
// tcp_err(pcb, tcp_err_callback);
|
||||
// return ERR_OK;
|
||||
// }
|
||||
|
||||
// int main(void) {
|
||||
// struct tcp_pcb *pcb1;
|
||||
// struct tcp_pcb *pcb2;
|
||||
// struct tcp_connection *conn1;
|
||||
// struct tcp_connection *conn2;
|
||||
|
||||
// // 初始化 STM32 硬件(例如以太网)
|
||||
// HAL_Init();
|
||||
// // 初始化 LwIP 协议栈
|
||||
// lwip_init();
|
||||
|
||||
// // 创建第一个 TCP PCB
|
||||
// pcb1 = tcp_new();
|
||||
// if (pcb1 == NULL) {
|
||||
// printf("Error creating TCP PCB1\n");
|
||||
// return -1;
|
||||
// }
|
||||
// if (tcp_bind(pcb1, IP_ADDR_ANY, PORT1)!= ERR_OK) {
|
||||
// printf("Error binding TCP PCB1 to port %d\n", PORT1);
|
||||
// tcp_close(pcb1);
|
||||
// return -1;
|
||||
// }
|
||||
// pcb1 = tcp_listen(pcb1);
|
||||
// conn1 = mem_malloc(sizeof(struct tcp_connection));
|
||||
// if (conn1 == NULL) {
|
||||
// tcp_close(pcb1);
|
||||
// return -1;
|
||||
// }
|
||||
// conn1->pcb = pcb1;
|
||||
// conn1->state = TCP_STATE_LISTEN;
|
||||
// tcp_arg(pcb1, conn1);
|
||||
// tcp_accept(pcb1, tcp_accept_callback);
|
||||
|
||||
// // 创建第二个 TCP PCB
|
||||
// pcb2 = tcp_new();
|
||||
// if (pcb2 == NULL) {
|
||||
// printf("Error creating TCP PCB2\n");
|
||||
// return -1;
|
||||
// }
|
||||
// if (tcp_bind(pcb2, IP_ADDR_ANY, PORT2)!= ERR_OK) {
|
||||
// printf("Error binding TCP PCB2 to port %d\n", PORT2);
|
||||
// tcp_close(pcb2);
|
||||
// return -1;
|
||||
// }
|
||||
// pcb2 = tcp_listen(pcb2);
|
||||
// conn2 = mem_malloc(sizeof(struct tcp_connection));
|
||||
// if (conn2 == NULL) {
|
||||
// tcp_close(pcb2);
|
||||
// return -1;
|
||||
// }
|
||||
// conn2->pcb = pcb2;
|
||||
// conn2->state = TCP_STATE_LISTEN;
|
||||
// tcp_arg(pcb2, conn2);
|
||||
// tcp_accept(pcb2, tcp_accept_callback);
|
||||
|
||||
// while (1) {
|
||||
// // 主循环中处理系统超时和其他任务
|
||||
// sys_check_timeouts();
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue