他的回复:
能不能详细讲下消息队列的,为啥我不能用LOS_QueueWrite传送一个字符串,我看这个函数的定义LITE_OS_SEC_TEXT UINT32 LOS_QueueWrite(UINT32 uwQueueID, VOID *pBufferAddr, UINT32 uwBufferSize, UINT32 uwTimeOut){ if(pBufferAddr == NULL) { return LOS_ERRNO_QUEUE_WRITE_PTR_NULL; } uwBufferSize = sizeof(UINT32*); return LOS_QueueWriteCopy(uwQueueID, &pBufferAddr, uwBufferSize, uwTimeOut);}uwBufferSize不是等于4 了么? 我直接用LOS_QueueWriteCopy就可以成功传送字符串了,但奇怪的是我是用LOS_QueueRead来接收的,并不需要使用对应的LOS_QueueReadCopy,烦请尽快更新吧!~ 想说支持国产真是不容易啊,还请高手指点 我测试的收发原码如下, KEY1只能发送一个?, KEY2就可以成功传送字符串UINT8 string1[]="hello linux\n"; //for Queue test UINT8 string2[]="hello world\n";static void StrQueueReceiveTask(void){ UINT32 uwRet = LOS_OK; UINT32 r_queue = 0; UINT32 *getDat; UINT8 rBuff[32] = {0}; UINT32 buffSize = 32; // while(1) { //buffSize should be a variable, not a const number, cause it transfer a buffSize address to QueueRead uwRet = LOS_QueueRead(g_strQueueHandle, rBuff, buffSize, LOS_WAIT_FOREVER); if (LOS_OK == uwRet) { printf("Read Queue message: %s \n", rBuff); //printf("Read Queue message: %s \n", r_str); //memset(r_str, 0, 20); } else { printf("Read Queue error,retCode: 0x%X\n",uwRet); } //LOS_QueueDelete(g_strQueueHandle); LOS_TaskDelay(10); }}static void StrQueueSendTask(void){ UINT32 uwRet = LOS_OK; UINT32 buffSize = 0; printf("String Queue Send Task run~\n"); while(1) { if (Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) { printf("Send string1\n"); buffSize = sizeof(string1); uwRet = LOS_QueueWrite(g_strQueueHandle, string1, buffSize+1, 0); if (LOS_OK != uwRet) printf("Write Queue: string1 failed,retCode= 0x%X\n",uwRet); } else if (Key_Scan(KEY2_GPIO_PORT, KEY2_GPIO_PIN) == KEY_ON) { printf("Send string2\n"); buffSize = sizeof(string2); uwRet = LOS_QueueWriteCopy(g_strQueueHandle, string2, buffSize+1, 0); if (LOS_OK != uwRet) printf("Write Queue: string2 failed,retCode= 0x%X\n",uwRet); } LOS_TaskDelay(30); }}