在线时间290 小时
UID198020
ST金币2456
蝴蝶豆32
注册时间2007-7-22
该用户从未签到
金牌会员
- 最后登录
- 2021-1-15
|
楼主 |
发表于 2018-10-7 21:02:27
|
显示全部楼层
你好, 中断处理方法如下:这个方法是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); //打印接收到的数据
}
}
}
}
|
|