Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread发布
cplusplus/queue.h文件BUG
发布于 2019-09-29 15:22:42 浏览:1735
订阅该版
```/* * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2016/10/1 Bernard The first version */ #pragma once #include
#include
#include
namespace rtthread { /** * The Queue class allow to control, send, receive, or wait for messages. * A message can be a integer or pointer value to a certain type T that is send * to a thread or interrupt service routine. * @param T data type of a single message element. * @param queue_sz maximum number of messages in queue. */ template
class Queue { public: /** Create and initialise a message Queue. */ Queue() { rt_mq_init(&mID, "mq", mPool, sizeof(T), sizeof(mPool), RT_IPC_FLAG_FIFO); }; ~Queue() { rt_mq_detach(&mID); }; /** Put a message in a Queue. @param data message pointer. @param millisec timeout value or 0 in case of no time-out. (default: 0) @return status code that indicates the execution status of the function. */ rt_err_t put(T& data, int32_t millisec = 0) { return rt_mq_send(&mID, &data, sizeof(data)); } /** Get a message or Wait for a message from a Queue. @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever). @return bool . */ bool get(T& data, int32_t millisec = WAIT_FOREVER) { rt_int32_t tick; if (millisec < 0) tick = -1; else tick = rt_tick_from_millisecond(millisec); return rt_mq_recv(&mID, &data, sizeof(data), tick) == RT_EOK; } private: struct rt_messagequeue mID; char mPool[(sizeof(struct rt_messagequeue) + sizeof(T)) * queue_sz]; }; }```以上是原文件。最后一句mPool的尺寸计算明显有问题,导致实际尺寸很大,严重浪费RAM(100个消息需要7KB左右),改成下面就好了:```char mPool[(sizeof(T)+4) * queue_sz];```另外我感觉软件定时器使用独立线程可能有BUG,因为我关闭这一个选项我的程序正常,开启就跑飞,调试显示的英文意思好像是线程混乱什么的。
查看更多
2
个回答
默认排序
按发布时间排序
tyustli
2019-09-30
这家伙很懒,什么也没写!
Queue.h 里面确实是个 bug ,楼主会使用 git 吗,大显身手的时候到了
DIOJ_8427
2019-10-09
这家伙很懒,什么也没写!
>Queue.h 里面确实是个 bug ,楼主会使用 git 吗,大显身手的时候到了 --- 不会,没有在github上提交过代码。
撰写答案
登录
注册新账号
关注者
0
被浏览
1.7k
关于作者
DIOJ_8427
这家伙很懒,什么也没写!
提问
6
回答
9
被采纳
0
关注TA
发私信
相关问题
1
RT-Thread单内核v0.2.2正式版
2
[发布] RT-Thread RTOS v0.2.3版本
3
RT-Thread 0.3.0 beta
4
RT-Thread/STM32 0.3.0 RC1发布
5
RT-Thread/LM3S 0.3.0 RC1版发布
6
建议弄个MIPS版本的。龙芯上用。
7
开源实时操作系统RT-Thread 0.3.0正式版发布
8
关于RT-THREAD的UDP讨论
9
这里是BUG回报板块!
10
rt-thread stm32 0.3.0 rc1 网络问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
RT-thred的stm32h723对应bsp包CubeMX添加其他外设报错
2
RT-Thread中的time溢出问题,时间戳溢出,解决方法
3
ART-PI使用env驱动ETH网卡,pc和板子可以ping通
4
SystemView线程名字不显示
5
只用网页也能跑RT-Smart 无门槛腾讯Cloud studio + smart-build快速构建
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
I2C_IIC
UART
ESP8266
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
keil_MDK
ulog
SFUD
msh
C++_cpp
MicroPython
本月问答贡献
RTT_逍遥
8
个答案
2
次被采纳
KunYi
8
个答案
1
次被采纳
三世执戟
7
个答案
1
次被采纳
winfeng
2
个答案
1
次被采纳
chenyaxing
2
个答案
1
次被采纳
本月文章贡献
catcatbing
2
篇文章
5
次点赞
swet123
1
篇文章
4
次点赞
Days
1
篇文章
3
次点赞
YZRD
1
篇文章
2
次点赞
阳光的掌控者
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部