仪表技术与传感器InstrumentTechniqueandSensor2023年第8期收稿日期:2023-02-01基于FreeRTOS的多连接TCPServer设计范亚南,高军科,韩文斌,魏亚伟(中国航空工业集团公司洛阳电光设备研究所,河南洛阳471009)摘要:文中提出了一种支持多客户端连接的TCPServer的嵌入式软硬件设计方案。该网络服务器以Cortex-M4芯片STM32F407VET6为核心控制器,通过RMII接口与LAN8742A以太网收发器进行网络数据交互。此外,文中将LwIP协议栈移植到FreeRTOS实时操作系统中,并根据TCP客户端连接情况,动态创建或消除相应客户端的网络通信线程。研究证明,TCPServer最大可支持4个客户端同时连接,进行稳定的网络数据传输,有效解决了嵌入式网络系统仅单点连接的问题。关键词:FreeRTOS;STM32F407;多连接TCPServer中图分类号:TP368文献标识码:A文章编号:1002-1841(2023)08-0096-05DesignofMulti-connectedTCPServerBasedonFreeRTOSFANYanan,GAOJunke,HANWenbin,WEIYawei(LuoyangInstituteofElectro-OpticalEquipment,AVIC,Luoyang471009,China)Abstract:Thispaperputforwardadesignschemeofsoftwareandhardwareformulti-connectedTCPServerinembeddedsystem.ThenetworkserverusedCortex-M4chipSTM32F407VET6asthecorecontroller,viaRMIIbusconnectedtoLAN8742AEthernettransceivertoprocessnetworkdata.Furthermore,theLwIPprotocolstackwastransplantedintoFreeRTOSreal-timeop-eratingsystem,andaccordingtotheconnectionsofTCPclients,theTCPservercandynamicallycreateanddeletethecorrespond-ingcommunicationprocessingthread.ResearchprovesthattheTCPServersupportsamaximumof4clientconnectionsforsteadynetworkdatatransmission,whichcaneffectivelysolvetheproblemofpointtopointconnectionforembeddednetworksystem.Keywords:FreeRTOS;STM32F407;multi-connectedTCPServer0引言以太网通信具有抗干扰性、实时性和高速率等特点。面向复杂应用环境设计的TCP/IP通信协议,具有自动纠错功能,通信质量稳定,不易受外部环境干扰,已应用于生产生活中的各个领域[1-3]。但是目前嵌入式系统的TCP/IP服务器,一般只能被单个TCP客户端连接,未能充分体现TCP/IP协议的功能,不能满足多个网络节点同时连接、分布式通信架构的现代化网络通信需求[4]。本文提出了一种以高性能微处理器Cortex-M4芯片STM32F407VET6和以太网收发器LAN8742A为核心的网络通信电路。通过FreeRTOS实现多线程任务管理...