diff options
Diffstat (limited to 'Linux_x86/phDal4Nfc.c')
-rw-r--r-- | Linux_x86/phDal4Nfc.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c index ec92566..9bedaf9 100644 --- a/Linux_x86/phDal4Nfc.c +++ b/Linux_x86/phDal4Nfc.c @@ -33,6 +33,8 @@ #include <stdlib.h> #ifdef ANDROID #include <linux/ipc.h> +#include <cutils/log.h> +#include <cutils/properties.h> // for property_get #else #include <sys/msg.h> #endif @@ -98,6 +100,7 @@ static phDal4Nfc_SContext_t gDalContext; static pphDal4Nfc_SContext_t pgDalContext; static phHal_sHwReference_t * pgDalHwContext; static sem_t nfc_read_sem; +static int low_level_traces; #ifdef USE_MQ_MESSAGE_QUEUE static phDal4Nfc_DeferredCall_Msg_t nDeferedMessage; static mqd_t nDeferedCallMessageQueueId; @@ -117,6 +120,31 @@ static void phDal4Nfc_FillMsg (phDal4Nfc_Message_t *pDalMsg, phOsalN DAL API IMPLEMENTATION ------------------------------------------------------------------------------------*/ +static void refresh_low_level_traces() { +#ifdef LOW_LEVEL_TRACES + low_level_traces = 1; + return; +#else + +#ifdef ANDROID + char value[PROPERTY_VALUE_MAX]; + + property_get("ro.debuggable", value, ""); + if (!value[0] || !atoi(value)) { + low_level_traces = 0; // user build, do not allow debug + return; + } + + property_get("debug.nfc.LOW_LEVEL_TRACES", value, ""); + if (value[0]) { + low_level_traces = atoi(value) ? 1 : 0; + return; + } +#endif + low_level_traces = 0; +#endif +} + /*----------------------------------------------------------------------------- FUNCTION: phDal4Nfc_Register @@ -216,6 +244,8 @@ NFCSTATUS phDal4Nfc_Init(void *pContext, void *pHwRef ) { NFCSTATUS result = NFCSTATUS_SUCCESS; + refresh_low_level_traces(); + if ((NULL != pContext) && (NULL != pHwRef)) { pContext = pgDalContext; @@ -530,7 +560,6 @@ NFCSTATUS phDal4Nfc_Config(pphDal4Nfc_sConfig_t config,void **phwref) gLinkFunc.open_and_configure = phDal4Nfc_uart_open_and_configure; gLinkFunc.read = phDal4Nfc_uart_read; gLinkFunc.write = phDal4Nfc_uart_write; - gLinkFunc.download = phDal4Nfc_uart_download; gLinkFunc.reset = phDal4Nfc_uart_reset; } break; @@ -605,7 +634,7 @@ NFCSTATUS phDal4Nfc_Reset(long level) { NFCSTATUS retstatus = NFCSTATUS_SUCCESS; - DAL_DEBUG("phDal4Nfc_Reset: VEN to %d",level); + DAL_DEBUG("phDal4Nfc_Reset: VEN to %ld",level); retstatus = gLinkFunc.reset(level); @@ -720,17 +749,19 @@ retry: else { i2c_error_count = 0; -#ifdef LOW_LEVEL_TRACES - phOsalNfc_PrintData("Received buffer", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer); -#endif + + if (low_level_traces) + { + phOsalNfc_PrintData("RECV", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer); + } 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[]={ "); +/* 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"); + DAL_PRINT("RX Thread }\n"); */ /* read completed immediately */ sMsg.eMsgType= PHDAL4NFC_READ_MESSAGE; @@ -867,9 +898,10 @@ void phDal4Nfc_DeferredCb (void *params) case PHDAL4NFC_WRITE_MESSAGE: DAL_PRINT(" Dal deferred write called \n"); -#ifdef LOW_LEVEL_TRACES - phOsalNfc_PrintData("Send buffer", (uint16_t)gReadWriteContext.nNbOfBytesToWrite, gReadWriteContext.pWriteBuffer); -#endif + if(low_level_traces) + { + phOsalNfc_PrintData("SEND", (uint16_t)gReadWriteContext.nNbOfBytesToWrite, gReadWriteContext.pWriteBuffer); + } /* DAL_DEBUG("dalMsg->transactInfo.length : %d\n", dalMsg->transactInfo.length); */ /* Make a Physical WRITE */ @@ -894,12 +926,12 @@ void phDal4Nfc_DeferredCb (void *params) DAL_PRINT(" Physical Write Success \n"); TransactionInfo.length=(uint16_t)gReadWriteContext.nNbOfBytesWritten; TransactionInfo.status=NFCSTATUS_SUCCESS; - DAL_PRINT("WriteBuff[]={ "); +/* DAL_PRINT("WriteBuff[]={ "); for (i = 0; i < gReadWriteContext.nNbOfBytesWritten; i++) { DAL_DEBUG("0x%x ", gReadWriteContext.pWriteBuffer[i]); } - DAL_PRINT("}\n"); + DAL_PRINT("}\n"); */ // Free TempWriteBuffer if(gReadWriteContext.pTempWriteBuffer != NULL) |