Skip to content

Commit

Permalink
Serial autoprobing is now DISABLED as default, fix Issue 58.
Browse files Browse the repository at this point in the history
  • Loading branch information
neomilium committed Jan 18, 2010
1 parent 1e2ccbf commit 2d4bdf2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions src/lib/drivers/arygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/drivers/pn532_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2d4bdf2

Please sign in to comment.