修复消息队列野指针的bug和队列长度计算异常的错误

This commit is contained in:
NeoZng
2022-12-01 13:07:55 +08:00
parent bcd7bf00e5
commit 063203bd68
5 changed files with 92 additions and 48 deletions

View File

@@ -33,6 +33,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "robot.h"
#include "message_center.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -64,7 +65,13 @@ void MX_FREERTOS_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
typedef struct
{
float a;
uint8_t b;
uint32_t c;
/* data */
}good;
/* USER CODE END 0 */
/**
@@ -113,6 +120,17 @@ int main(void)
RobotInit();
good asdf;
good asdfsadf;
good pub={.a=1,.b=2,.c=3};
Subscriber_t* s=SubRegister("test\0",sizeof(good));
Subscriber_t* ss=SubRegister("test\0",sizeof(good));
Publisher_t* p=PubRegister("test\0",sizeof(asdf));
PubPushMessage(p,&pub);
PubPushMessage(p,&pub);
volatile uint8_t d= SubGetMessage(s,&asdf);
d=SubGetMessage(s,&asdf);
d=SubGetMessage(ss,&asdfsadf);
/* USER CODE END 2 */
/* Call init function for freertos objects (in freertos.c) */