大家好,我在做IFIFO测试的时候,遭遇了IFIFO读取数据失败,代码如下:
Write程序:
- C/C++ code
#define STR_TEST_FIFO_W "fifo:/~/foobar?mode=w"boolean BrewFifoWrite_InitAppData(BrewFifoWrite* pMe){ int nRet = 0; pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo); ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo); nRet = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FIFO, &pMe->m_pIFIFO); nRet = IFIFO_Open(pMe->m_pIFIFO, STR_TEST_FIFO_W); return TRUE;}void BrewFifoWrite_FreeAppData(BrewFifoWrite* pMe){ IFIFO_Close(pMe->m_pIFIFO);}// 在按1的时候,对IFIFO写数据:case EVT_KEY: switch (wParam) { case AVK_1: { PrintInfo(pMe->a.m_pIDisplay, szPost); Mms_StartPostMessage(pMe); }// 写数据的实现:void Mms_StartPostMessage(BrewFifoWrite* pMe){ uint8 DataBuffer[MAX_BUFFER_SIZE] = {'t', 'e', 's', 't', ' ', 'f', 'i', 'f', 'o', 0}; int nRet; int nFileSize; // 向IFIFO中写数据 nRet = IFIFO_Write(pMe->m_pIFIFO, DataBuffer, STRLEN(DataBuffer) * sizeof(uint8)); // 启动读程序 nRet = ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BREWFIFOREAD); // 发信号告诉读程序,可以读取消息了 nRet = ISHELL_PostEvent(pMe->a.m_pIShell, AEECLSID_BREWFIFOREAD, UEVT_READ_FIFO, 0, 0);}
读程序:
- C/C++ code
// 在收到消息UEVT_READ_FIFOcase UEVT_READ_FIFO: Mms_StartGetMessage(pMe); return TRUE;// 读IFIFO的实现#define STR_TEST_FIFO_R "fifo:/~/foobar?mode=r"void Mms_StartGetMessage(BrewFifoRead* pMe){ IFIFO* pIFIFO; int nRet; uint8* pucDataBuffer; pucDataBuffer = (uint8*)MALLOC(sizeof(uint8) * MAX_BUFFER_SIZE); nRet = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FIFO, &pIFIFO); nRet = IFIFO_Open(pIFIFO, STR_TEST_FIFO_R); nRet = IFIFO_Read(pIFIFO, pucDataBuffer, MAX_BUFFER_SIZE); IFIFO_Close(pIFIFO); return;}
我调试的时候,发现已经向IFIFO中写了9个字节的数据,但是为什么我在读取程序里却收不到呢?
------解决方案--------------------------------------------------------
你这是那套sdk上的?没印象有IFIFO这个接口,自己写的扩展类?