回答

收藏

freertos 的 queue队列出错

STMCU STMCU 5339 人阅读 | 0 人回复 | 2016-09-20

在用M4跑FREERTOS的时候,队列出错。


找到出错的代码:
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
经过研究是这一句话报错。
开始分析:
里面2个条件成立才会报错。

pvItemToQueue == NULL。这句话是这样解释的,指向将要放到队列的数据指针。item 是队列的一组数据。
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue.  The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.

pxQueue->uxItemSize 这个参数是什么? 队列保持的每组数据的长度。
UBaseType_t uxItemSize;                        /*< The size of each items that the queue will hold. */

综合起来,指向的数据为空,但是长度不为0.
那就是说要发送的数据为空,你还调用了队列的send函数。至此原因已经找到。

BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition )
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
Queue_t * const pxQueue = ( Queue_t * ) xQueue;

        configASSERT( pxQueue );
        // 如果这里出问题,那么pvItemToQueue是NULL, pxQueue->uxItemSize不等于0,是不是就是说,长度不为0,但是没数据的意思?
        //这句话究竟是什么意思?
        configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
}
qhq





分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条