From 4b276c94d7a3286d8b73fdbd975053651b4cf989 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Tue, 14 Jun 2011 17:47:30 -0700 Subject: Misc changes for Nexus Prime bringup. o Fix uart read() implementation o Temporarily disable firmware update o Rename ttySx to ttyOx (this should be properly abstracted later) o Bug fix in #ifdef code o Update verbose logging arguments Change-Id: I87814e2be9ddbf5036d5586a2fd82311d56ec47f --- Linux_x86/phDal4Nfc.c | 2 +- Linux_x86/phDal4Nfc_uart.c | 57 +++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 29 deletions(-) (limited to 'Linux_x86') diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c index 87def2b..1b6da83 100644 --- a/Linux_x86/phDal4Nfc.c +++ b/Linux_x86/phDal4Nfc.c @@ -126,7 +126,7 @@ static void refresh_low_level_traces() { 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); + DAL_DEBUG("debug.nfc.LOW_LEVEL_TRACES = %X", low_level_traces); } #endif diff --git a/Linux_x86/phDal4Nfc_uart.c b/Linux_x86/phDal4Nfc_uart.c index 30cb500..c4526e0 100644 --- a/Linux_x86/phDal4Nfc_uart.c +++ b/Linux_x86/phDal4Nfc_uart.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -161,28 +162,28 @@ NFCSTATUS phDal4Nfc_uart_open_and_configure(pphDal4Nfc_sConfig_t pConfig, void * switch(pConfig->nLinkType) { case ENUM_DAL_LINK_TYPE_COM1: - pComPort = "/dev/ttyS0"; + pComPort = "/dev/ttyO0"; break; case ENUM_DAL_LINK_TYPE_COM2: - pComPort = "/dev/ttyS1"; + pComPort = "/dev/ttyO1"; break; case ENUM_DAL_LINK_TYPE_COM3: - pComPort = "/dev/ttyS2"; + pComPort = "/dev/ttyO2"; break; case ENUM_DAL_LINK_TYPE_COM4: - pComPort = "/dev/ttyS3"; + pComPort = "/dev/ttyO3"; break; case ENUM_DAL_LINK_TYPE_COM5: - pComPort = "/dev/ttyS4"; + pComPort = "/dev/ttyO4"; break; case ENUM_DAL_LINK_TYPE_COM6: - pComPort = "/dev/ttyS5"; + pComPort = "/dev/ttyO5"; break; case ENUM_DAL_LINK_TYPE_COM7: - pComPort = "/dev/ttyS6"; + pComPort = "/dev/ttyO6"; break; case ENUM_DAL_LINK_TYPE_COM8: - pComPort = "/dev/ttyS7"; + pComPort = "/dev/ttyO7"; break; case ENUM_DAL_LINK_TYPE_USB: pComPort = "/dev/ttyUSB0"; @@ -263,31 +264,31 @@ PURPOSE: Reads nNbBytesToRead bytes and writes them in pBuffer. Returns the number of bytes really read or -1 in case of error. -----------------------------------------------------------------------------*/ - int phDal4Nfc_uart_read(uint8_t * pBuffer, int nNbBytesToRead) { - fd_set rfds; - struct timeval tv; int ret; + int numRead = 0; DAL_ASSERT_STR(gComPortContext.nOpened == 1, "read called but not opened!"); - - FD_ZERO(&rfds); - FD_SET(gComPortContext.nHandle, &rfds); - - /* select will block for 10 sec */ - tv.tv_sec = 2; - tv.tv_usec = 0; - - ret = select(gComPortContext.nHandle + 1, &rfds, NULL, NULL, &tv); - - if (ret == -1) - return -1; - - if (ret) - return read(gComPortContext.nHandle, pBuffer, nNbBytesToRead); - - return 0; + DAL_DEBUG("_uart_read() called to read %d bytes", nNbBytesToRead); + + while (numRead != nNbBytesToRead) { + ret = read(gComPortContext.nHandle, pBuffer + numRead, nNbBytesToRead - numRead); + if (ret > 0) { + DAL_DEBUG("read %d bytes", ret); + numRead += ret; + } else if (ret == 0) { + DAL_PRINT("_uart_read() EOF"); + return 0; + } else { + DAL_DEBUG("_uart_read() errno=%d", errno); + if (errno == EINTR || errno == EAGAIN) { + continue; + } + return -1; + } + } + return numRead; } /*----------------------------------------------------------------------------- -- cgit v1.2.3