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_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_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)
SET(libdir ${CMAKE_INSTALL_LIBDIR})
@ -42,9 +42,9 @@ IF(NOT DEFINED SHARE_INSTALL_PREFIX)
SET(SHARE_INSTALL_PREFIX share)
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
IF(LIBNFC_DISABLE_SERIAL_AUTOPROBE)
ADD_DEFINITIONS("-DDISABLE_SERIAL_AUTOPROBE")
ENDIF(LIBNFC_DISABLE_SERIAL_AUTOPROBE)
IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED")
ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
IF(LIBNFC_DEBUG_OUTPUT)
ADD_DEFINITIONS(-DDEBUG -g3)

View file

@ -58,15 +58,15 @@ then
fi
AC_SUBST([DEBUG_CFLAGS])
# Serial autoprobing support (default:yes)
AC_ARG_ENABLE([serial-autoprobe],AS_HELP_STRING([--disable-serial-autoprobe],[Disable serial autoprobing]),[enable_serial_autoprobe=$enableval],[enable_serial_autoprobe="yes"])
# Serial autoprobing support (default:no)
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_RESULT($enable_serial_autoprobe)
if test x"$enable_serial_autoprobe" = "xno"
if test x"$enable_serial_autoprobe" = "xyes"
then
CFLAGS="$CFLAGS -DDISABLE_SERIAL_AUTOPROBE"
CFLAGS="$CFLAGS -DSERIAL_AUTOPROBE_ENABLED"
fi
# PCSC-lite support (default: yes)

View file

@ -2,9 +2,9 @@ IF(LIBNFC_VERBOSE_OUTPUT)
ADD_DEFINITIONS("-DDEBUG")
ENDIF(LIBNFC_VERBOSE_OUTPUT)
IF(LIBNFC_DISABLE_SERIAL_AUTOPROBE)
ADD_DEFINITIONS("-DDISABLE_SERIAL_AUTOPROBE")
ENDIF(LIBNFC_DISABLE_SERIAL_AUTOPROBE)
IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED")
ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
IF(LIBNFC_LANG_C99 AND NOT MSVC)
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;
if( pndd == NULL ) {
#ifdef DISABLE_SERIAL_AUTOPROBE
#ifndef SERIAL_AUTOPROBE_ENABLED
INFO("Sorry, serial auto-probing have been disabled at compile time.");
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);
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround
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);
#endif /* DEBUG */
}
#endif
#endif /* SERIAL_AUTOPROBE_ENABLED */
// Test if we have found a device
if (uiDevNr == DRIVERS_MAX_DEVICES) return NULL;
} 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 */
*pszDeviceFound = 0;
#ifdef DISABLE_SERIAL_AUTOPROBE
#ifndef SERIAL_AUTOPROBE_ENABLED
INFO("Sorry, serial auto-probing have been disabled at compile time.");
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
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);
#endif /* DEBUG */
}
#endif
#endif /* SERIAL_AUTOPROBE_ENABLED */
return true;
}