本帖最后由 hpdell 于 2018-10-3 16:01 编辑 请教下,使用FreeRTOS+LwIP+emWin 组合,目前接收有时不够灵敏 使用的 是 socket udp ,开发版发送数据 到电脑端貌似没有问题,但是 电脑端 使用 网络调试助手V4.2.1 这个工具发送数据给开发板, 有时会丢失数据 ?? 电脑端是 每s 发送一次 FreeRTOS+LwIP 是参考官方的历程修改,emwin 是我自己加上去的,正常来说,emwin 应该也不会影响到 FreeRTOS+LwIP的功能吧 ? |
我使用 f777
你好, 中断处理方法如下:这个方法是st 历程里面提供的,我也是参考这个方法来改的程序
在中断接收里面发送信息
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
{
osSemaphoreRelease(s_xSemaphore); //发送信号量
}
任务接收到发送来的信号量函数处理:
/**
* This function should be called when a packet is ready to be read
* from the interface. It uses the function low_level_input() that
* should handle the actual reception of bytes from the network
* interface. Then the type of the received packet is determined and
* the appropriate input function is called.
*
* @param netif the lwip network interface structure for this ethernetif
*/
void ethernetif_input( void const * argument )
{
struct pbuf *p;
struct netif *netif = (struct netif *) argument;
for( ;; )
{
if (osSemaphoreWait( s_xSemaphore, TIME_WAITING_FOR_INPUT) ==osOK)
{
do
{
p = low_level_input( netif );
if (p != NULL)
{
if (netif->input( p, netif) != ERR_OK )
{
pbuf_free(p);
p = NULL;
}
}
} while(p != NULL);
}
}
}
单独建立了一个任务,用于不停的查询接收到的数据,然后使用串口输出:
是不是我的这个任务的处理方法不对啊 ????????????????????????????????????????????
void socket_demo_RxDataProcess(void)
{
if(ReadConnectStatus()) // 如果连接成功才运行程序
{
int _s;
{
_s = recvfrom(xClientSocket.s,Socket_RecvBuf,TCP_RX_BUFSIZE,0,(struct sockaddr*)&ServerAddr,&addrlen);
if(_s > 0) //接收的数据
{
Socket_RecvBuf[_s] = '\0';
USART_OS_Printf("%s\r\n",Socket_RecvBuf); //打印接收到的数据
}
}
}
}