不带系统时候以太接口已调通。
按照例程
STM32H7-LwIP-Examples-mainSTM32H743_Nucleo_ETH 配置完系统后仅默认任务时ping只返回一两包数据,之后程序永远无法ping通。
重新创建任务,tcp-c连接多次才能成功,成功后只能发送一包数据到s端,之后程序卡死。
int sock = -1; struct sockaddr_in client_addr; uint8_t DEST_ADDRESS[4]={192,168,1,99}; ip4_addr_t ipaddr; while((pdTRUE == xSemaphoreTake(xLWIP_Init, 0)));//网口初始化完成后再执行tcp任务 IP4_ADDR( ipaddr, DEST_ADDRESS[0],DEST_ADDRESS[1],DEST_ADDRESS[2],DEST_ADDRESS[3]); char sendbuf[]="test"; while (1){ sock = socket(AF_INET, SOCK_STREAM, 0); if(sock < 0){ vTaskDelay(100); con
tinue; } #define DEST_PORT 5555 client_addr.sin_family = AF_INET; client_addr.sin_port = htons(DEST_PORT); client_addr.sin_addr.s_addr = ipaddr.addr; memset( (client_addr.sin_zero), 0, sizeof(client_addr.sin_zero)); if(connect(sock, (struct sockaddr*) client_addr, sizeof(struct sockaddr)) == -1){ vTaskDelay(100); closesocket(sock); vTaskDelay(100); continue; } while (1){ if(write(sock,sendbuf,sizeof(sendbuf))<0){ vTaskDelay(100); break; } m=0; vTaskDelay(100); } closesocket(sock);