查看: 3651|回复: 0

freertos 的 queue队列出错

[复制链接]
  • TA的每日心情
    无聊
    2016-12-23 14:05
  • 签到天数: 7 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    发表于 2016-9-20 15:40:50 | 显示全部楼层 |阅读模式
    分享到:
    在用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





    回复

    使用道具 举报

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

    本版积分规则



    手机版|小黑屋|与非网

    GMT+8, 2024-4-23 20:23 , Processed in 0.109608 second(s), 15 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.