初级会员
- 积分
- 188
- 金钱
- 188
- 注册时间
- 2018-7-11
- 在线时间
- 38 小时
|
8金钱
背景:743跑FreeRTOS + LWIP协议 作为主机,串口是UART8 ,网口也是独立的引脚 ;
现在的思路是IO触发数据发送,通过UDP发送数据
问题是1.串口打开时IO中断触发后,UDP采用LWIP协议发送的数据时出现了“系统级”错误vPortEnterCritical(),导致UDP的数据发送不出去,没有UDP发送的IO触发就没问题
2.关闭串口时,UDP发送数据正常
IO中断处理如下:
[mw_shl_code=c,true]/**
* IO中断函数
*/
void EXTI4_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
}[/mw_shl_code]
[mw_shl_code=c,true]void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
//消抖未做
switch(GPIO_Pin)
{
case GPIO_PIN_4:
xQueueSendFromISR(SafetyInputIOQueue,(void *)&SafetyIOCp->SafetyInputIO_Msg_Send,&xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
break;
}[/mw_shl_code]
UDP采用定时器往外发送
[mw_shl_code=applescript,true]void APP_Timer_Callback(void){
uint8_t i;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
timer_use_data.api_cansend.len = CANTmSdCop->Cache_SendP->Motor_Data.len;
timer_use_data.api_cansend.type = CAN_EXTENTED_FRAME;
Api_CandataSend(&timer_use_data.api_cansend);
......//此处省略
UDPTmSdCop->Cache_SendP->status = FREE;
UDPTmSdCop->Cache_SendP = UDPTmSdCop->Cache_SendP->next;
UDPTmSdCop->collect_time = 0;
xQueueSendFromISR(socketsendQueue,(void *)&timer_use_data.socketsend,0);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);[/mw_shl_code]
[mw_shl_code=applescript,true]/** 功能:UDP数据发送线程
***
*** 参数:
*** 返回:
*/
static void UdpSend_Thread(void *arg) {
struct socket_contrl_struct *SocketContrlp;
int i;
err_t err;
struct socket_queue_msg socketsend;
struct socket_sendcache_struct *socket_sendp;
uint8_t send_num;
//socket_contrl.p = pbuf_alloc(PBUF_TRANSPORT,socket_sendp->socket_baseinfo.len.sendlen,PBUF_RAM);
SocketContrlp = socket_contrlp;
for(;;) {
xQueueReceive(socketsendQueue,&socketsend,portMAX_DELAY);
socket_sendp = socketsend.socket_sendp;
send_num = socketsend.send_num;
for(i=0; i<send_num; i++) {
if(socket_sendp->status == DATAON)
{
// printf("socket_sendp->status == DATAON \r\n");
SocketContrlp->socketsend_buf.addr = socket_sendp->socket_baseinfo.addr;
SocketContrlp->socketsend_buf.port = socket_sendp->socket_baseinfo.port;
socket_sendp->p = pbuf_alloc(PBUF_TRANSPORT,socket_sendp->socket_baseinfo.len.sendlen,PBUF_RAM);
pbuf_take(socket_sendp->p,(char *)socket_sendp->send_data,socket_sendp->socket_baseinfo.len.sendlen);
SocketContrlp->socketsend_buf.p = SocketContrlp->socketsend_buf.ptr = socket_sendp->p;
//pbuf_take(socket_contrl.p,(char *)socket_sendp->send_data,socket_sendp->socket_baseinfo.len.sendlen);
//socket_contrl.socketsend_buf.p = socket_contrl.socketsend_buf.ptr = socket_contrl.p;
err = netconn_send(SocketContrlp->socket_conn, &SocketContrlp->socketsend_buf);
if(err != ERR_OK)
{
printf("err != ERR_OK .\r\n");
} else
{
// printf("err != ERR_OK taskENTER_CRITICAL .\r\n");
//taskENTER_CRITICAL();
socket_sendp->status = FREE;
pbuf_free(socket_sendp->p);
//taskEXIT_CRITICAL();
}
}
socket_sendp = socket_sendp->next;
}
//socket_sendp->status = FREE;
}
}[/mw_shl_code]
|
|