From 4812a72ceaada294477b4c2015c42cb8bcbe93a4 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Tue, 7 Jun 2011 10:37:09 -0700 Subject: Patch to dynamically enable NFC LOW_LEVEL_TRACES low level traces can be enabled at run-time with: adb shell setprop debug.nfc.LOW_LEVEL_TRACES 1 and disabled with adb shell setprop debug.nfc.LOW_LEVEL_TRACES 0 NFC must be turned off and on again for this change to take affect. Change-Id: Iefdc4873b3ee5bc697f34b307c22c06a6eda0667 Signed-off-by: Nick Pelly --- Linux_x86/phDal4Nfc.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'Linux_x86') diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c index a8803e2..2428f6c 100644 --- a/Linux_x86/phDal4Nfc.c +++ b/Linux_x86/phDal4Nfc.c @@ -33,6 +33,8 @@ #include #ifdef ANDROID #include +#include +#include // for property_get #else #include #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,21 @@ static void phDal4Nfc_FillMsg (phDal4Nfc_Message_t *pDalMsg, phOsalN DAL API IMPLEMENTATION ------------------------------------------------------------------------------------*/ +static void refresh_low_level_traces() { +#ifdef ANDROID + char value[1]; + property_get("debug.nfc.LOW_LEVEL_TRACES", value, ""); + if (value[0]) { + low_level_traces = atoi(value); + DAL_DEBUG("debug.nfc.LOW_LEVEL_TRACES = %X", mode); + } +#endif + +#ifdef LOW_LEVEL_TRACES + low_level_traces = 1; +#endif +} + /*----------------------------------------------------------------------------- FUNCTION: phDal4Nfc_Register @@ -216,6 +234,8 @@ NFCSTATUS phDal4Nfc_Init(void *pContext, void *pHwRef ) { NFCSTATUS result = NFCSTATUS_SUCCESS; + refresh_low_level_traces(); + if ((NULL != pContext) && (NULL != pHwRef)) { pContext = pgDalContext; @@ -707,9 +727,11 @@ 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("Received buffer", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer); + } DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead); DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead); DAL_PRINT("ReadBuff[]={ "); @@ -851,9 +873,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 buffer", (uint16_t)gReadWriteContext.nNbOfBytesToWrite, gReadWriteContext.pWriteBuffer); + } /* DAL_DEBUG("dalMsg->transactInfo.length : %d\n", dalMsg->transactInfo.length); */ /* Make a Physical WRITE */ -- cgit v1.1