Serial autoprobing is now DISABLED as default, fix Issue 58.

This commit is contained in:
Romuald Conty 2010-01-18 11:23:07 +00:00
parent 1e2ccbf9ff
commit 2d4bdf28a1
5 changed files with 18 additions and 17 deletions

View file

@ -22,7 +22,7 @@ INCLUDE(UseDoxygen)
SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip") SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support (ACR122)") SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support (ACR122)")
SET(LIBNFC_USB ON CACHE BOOL "Enable direct USB communication support (PN531 and PN533)") SET(LIBNFC_USB ON CACHE BOOL "Enable direct USB communication support (PN531 and PN533)")
SET(LIBNFC_DISABLE_SERIAL_AUTOPROBE OFF CACHE BOOL "Disable serial autoprobe") SET(LIBNFC_SERIAL_AUTOPROBE_ENABLED OFF CACHE BOOL "Allow serial ports to be probed (can seriously disturb connected serial devices)")
IF(DEFINED CMAKE_INSTALL_LIBDIR) IF(DEFINED CMAKE_INSTALL_LIBDIR)
SET(libdir ${CMAKE_INSTALL_LIBDIR}) SET(libdir ${CMAKE_INSTALL_LIBDIR})
@ -42,9 +42,9 @@ IF(NOT DEFINED SHARE_INSTALL_PREFIX)
SET(SHARE_INSTALL_PREFIX share) SET(SHARE_INSTALL_PREFIX share)
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX) ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
IF(LIBNFC_DISABLE_SERIAL_AUTOPROBE) IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
ADD_DEFINITIONS("-DDISABLE_SERIAL_AUTOPROBE") ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED")
ENDIF(LIBNFC_DISABLE_SERIAL_AUTOPROBE) ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
IF(LIBNFC_DEBUG_OUTPUT) IF(LIBNFC_DEBUG_OUTPUT)
ADD_DEFINITIONS(-DDEBUG -g3) ADD_DEFINITIONS(-DDEBUG -g3)

View file

@ -58,15 +58,15 @@ then
fi fi
AC_SUBST([DEBUG_CFLAGS]) AC_SUBST([DEBUG_CFLAGS])
# Serial autoprobing support (default:yes) # Serial autoprobing support (default:no)
AC_ARG_ENABLE([serial-autoprobe],AS_HELP_STRING([--disable-serial-autoprobe],[Disable serial autoprobing]),[enable_serial_autoprobe=$enableval],[enable_serial_autoprobe="yes"]) AC_ARG_ENABLE([serial-autoprobe],AS_HELP_STRING([--enable-serial-autoprobe],[Allow serial ports to be probed (can seriously disturb connected serial devices)]),[enable_serial_autoprobe=$enableval],[enable_serial_autoprobe="no"])
AC_MSG_CHECKING(for serial autoprobe flag) AC_MSG_CHECKING(for serial autoprobe flag)
AC_MSG_RESULT($enable_serial_autoprobe) AC_MSG_RESULT($enable_serial_autoprobe)
if test x"$enable_serial_autoprobe" = "xno" if test x"$enable_serial_autoprobe" = "xyes"
then then
CFLAGS="$CFLAGS -DDISABLE_SERIAL_AUTOPROBE" CFLAGS="$CFLAGS -DSERIAL_AUTOPROBE_ENABLED"
fi fi
# PCSC-lite support (default: yes) # PCSC-lite support (default: yes)

View file

@ -2,9 +2,9 @@ IF(LIBNFC_VERBOSE_OUTPUT)
ADD_DEFINITIONS("-DDEBUG") ADD_DEFINITIONS("-DDEBUG")
ENDIF(LIBNFC_VERBOSE_OUTPUT) ENDIF(LIBNFC_VERBOSE_OUTPUT)
IF(LIBNFC_DISABLE_SERIAL_AUTOPROBE) IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
ADD_DEFINITIONS("-DDISABLE_SERIAL_AUTOPROBE") ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED")
ENDIF(LIBNFC_DISABLE_SERIAL_AUTOPROBE) ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
IF(LIBNFC_LANG_C99 AND NOT MSVC) IF(LIBNFC_LANG_C99 AND NOT MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

View file

@ -95,10 +95,10 @@ nfc_device_t* arygon_connect(const nfc_device_desc_t* pndd)
nfc_device_t* pnd = NULL; nfc_device_t* pnd = NULL;
if( pndd == NULL ) { if( pndd == NULL ) {
#ifdef DISABLE_SERIAL_AUTOPROBE #ifndef SERIAL_AUTOPROBE_ENABLED
INFO("Sorry, serial auto-probing have been disabled at compile time."); INFO("Sorry, serial auto-probing have been disabled at compile time.");
return NULL; return NULL;
#else #else /* SERIAL_AUTOPROBE_ENABLED */
DBG("Trying to find ARYGON device on serial port: %s# at %d bauds.",SERIAL_STRING, SERIAL_DEFAULT_PORT_SPEED); DBG("Trying to find ARYGON device on serial port: %s# at %d bauds.",SERIAL_STRING, SERIAL_DEFAULT_PORT_SPEED);
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround // I have no idea how MAC OS X deals with multiple devices, so a quick workaround
for (uiDevNr=0; uiDevNr<DRIVERS_MAX_DEVICES; uiDevNr++) for (uiDevNr=0; uiDevNr<DRIVERS_MAX_DEVICES; uiDevNr++)
@ -120,7 +120,8 @@ nfc_device_t* arygon_connect(const nfc_device_desc_t* pndd)
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acConnect); if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acConnect);
#endif /* DEBUG */ #endif /* DEBUG */
} }
#endif #endif /* SERIAL_AUTOPROBE_ENABLED */
// Test if we have found a device // Test if we have found a device
if (uiDevNr == DRIVERS_MAX_DEVICES) return NULL; if (uiDevNr == DRIVERS_MAX_DEVICES) return NULL;
} else { } else {

View file

@ -96,10 +96,10 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_
* have serious problem with other device on this bus */ * have serious problem with other device on this bus */
*pszDeviceFound = 0; *pszDeviceFound = 0;
#ifdef DISABLE_SERIAL_AUTOPROBE #ifndef SERIAL_AUTOPROBE_ENABLED
INFO("Sorry, serial auto-probing have been disabled at compile time."); INFO("Sorry, serial auto-probing have been disabled at compile time.");
return false; return false;
#else /* DISABLE_SERIAL_AUTOPROBE */ #else /* SERIAL_AUTOPROBE_ENABLED */
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround // I have no idea how MAC OS X deals with multiple devices, so a quick workaround
for (iDevice=0; iDevice<DRIVERS_MAX_DEVICES; iDevice++) for (iDevice=0; iDevice<DRIVERS_MAX_DEVICES; iDevice++)
@ -134,7 +134,7 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acConnect); if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acConnect);
#endif /* DEBUG */ #endif /* DEBUG */
} }
#endif #endif /* SERIAL_AUTOPROBE_ENABLED */
return true; return true;
} }