本文整理汇总了C++中phDal4Nfc_link_cbk_interface_t::read方法的典型用法代码示例。如果您正苦于以下问题:C++ phDal4Nfc_link_cbk_interface_t::read方法的具体用法?C++ phDal4Nfc_link_cbk_interface_t::read怎么用?C++ phDal4Nfc_link_cbk_interface_t::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phDal4Nfc_link_cbk_interface_t
的用法示例。
在下文中一共展示了phDal4Nfc_link_cbk_interface_t::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: phDal4Nfc_ReaderThread
int phDal4Nfc_ReaderThread(void * pArg)
{
char retvalue;
NFCSTATUS result = NFCSTATUS_SUCCESS;
uint8_t retry_cnt=0;
void * memsetRet;
static int MsgType= PHDAL4NFC_READ_MESSAGE;
int * pmsgType=&MsgType;
phDal4Nfc_Message_t sMsg;
phOsalNfc_Message_t OsalMsg ;
int i;
int i2c_error_count;
pthread_setname_np(pthread_self(), "reader");
/* Create the overlapped event. Must be closed before exiting
to avoid a handle leak. This event is used READ API and the Reader thread*/
DAL_PRINT("RX Thread \n");
DAL_DEBUG("\nRX Thread nReadThreadAlive = %d",gReadWriteContext.nReadThreadAlive);
DAL_DEBUG("\nRX Thread nWaitingOnRead = %d",gReadWriteContext.nWaitingOnRead);
while(gReadWriteContext.nReadThreadAlive) /* Thread Loop */
{
/* Check for the read request from user */
DAL_PRINT("RX Thread Sem Lock\n");
sem_wait(&nfc_read_sem);
DAL_PRINT("RX Thread Sem UnLock\n");
if (!gReadWriteContext.nReadThreadAlive)
{
/* got the signal that we should exit. NOTE: we don't
attempt to read below, since the read may block */
break;
}
/* Issue read operation.*/
i2c_error_count = 0;
retry:
gReadWriteContext.nNbOfBytesRead=0;
DAL_DEBUG("RX Thread *New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
/* Wait for IRQ !!! */
gReadWriteContext.nNbOfBytesRead = gLinkFunc.read(gReadWriteContext.pReadBuffer, gReadWriteContext.nNbOfBytesToRead);
/* TODO: Remove this hack
* Reading the value 0x57 indicates a HW I2C error at I2C address 0x57
* (pn544). There should not be false positives because a read of length 1
* must be a HCI length read, and a length of 0x57 is impossible (max is 33).
*/
if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
{
i2c_error_count++;
DAL_DEBUG("RX Thread Read 0x57 %d times\n", i2c_error_count);
if (i2c_error_count < 5) {
usleep(2000);
goto retry;
}
DAL_PRINT("RX Thread NOTHING TO READ, RECOVER");
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
else
{
i2c_error_count = 0;
#ifdef LOW_LEVEL_TRACES
phOsalNfc_PrintData("Received buffer", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer);
#endif
DAL_DEBUG("RX Thread Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
DAL_DEBUG("RX Thread NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
DAL_PRINT("RX Thread ReadBuff[]={ ");
for (i = 0; i < gReadWriteContext.nNbOfBytesRead; i++)
{
DAL_DEBUG("RX Thread 0x%x ", gReadWriteContext.pReadBuffer[i]);
}
DAL_PRINT("RX Thread }\n");
/* read completed immediately */
sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE;
/* Update the state */
phDal4Nfc_FillMsg(&sMsg,&OsalMsg);
phDal4Nfc_DeferredCall((pphDal4Nfc_DeferFuncPointer_t)phDal4Nfc_DeferredCb,(void *)pmsgType);
memsetRet=memset(&sMsg,0,sizeof(phDal4Nfc_Message_t));
memsetRet=memset(&OsalMsg,0,sizeof(phOsalNfc_Message_t));
}
} /* End of thread Loop*/
DAL_PRINT("RX Thread exiting");
return TRUE;
}