some cleanings

This commit is contained in:
Unknown 2020-07-07 19:40:46 +02:00
parent e21fab3685
commit 7ad18a2120
16 changed files with 135 additions and 342 deletions

View file

@ -29,23 +29,23 @@ IF(UART_REQUIRED)
ENDIF(UART_REQUIRED)
IF(I2C_REQUIRED)
IF(WIN32)
# Windows is not supported at the moment
IF(NOT UNIX OR APPLE)
# Only Linux is supported at the moment
#LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/i2c)
MESSAGE( FATAL_ERROR "I2C not (yet) supported under Windows!" )
ELSE(WIN32)
MESSAGE( FATAL_ERROR "I2C is only (yet) supported in Linux!" )
ELSE(NOT UNIX OR APPLE)
LIST(APPEND BUSES_SOURCES buses/i2c)
ENDIF(WIN32)
ENDIF(NOT UNIX OR APPLE)
ENDIF(I2C_REQUIRED)
IF(SPI_REQUIRED)
IF(WIN32)
# Windows is not supported at the moment
IF(NOT UNIX OR APPLE)
# Only Linux is supported at the moment
#LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/spi)
MESSAGE( FATAL_ERROR "SPI not (yet) supported under Windows!" )
ELSE(WIN32)
MESSAGE( FATAL_ERROR "SPI is only (yet) supported in Linux!" )
ELSE(NOT UNIX OR APPLE)
LIST(APPEND BUSES_SOURCES buses/spi)
ENDIF(WIN32)
ENDIF(NOT UNIX OR APPLE)
ENDIF(SPI_REQUIRED)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses)
@ -66,7 +66,9 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
IF(LIBNFC_LOG)
IF(WIN32)
SET(CMAKE_C_FLAGS "-fgnu89-inline ${CMAKE_C_FLAGS}")
IF(MINGW)
SET(CMAKE_C_FLAGS "-fgnu89-inline ${CMAKE_C_FLAGS}")
ENDIF(MINGW)
LIST(APPEND LIBRARY_SOURCES log ../contrib/win32/libnfc/log-internal)
ELSE(WIN32)
LIST(APPEND LIBRARY_SOURCES log log-internal)

View file

@ -1208,7 +1208,7 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
// send ICLASS_ACTIVATE_ALL command - will get timeout as we don't expect response
uint8_t abtReqt[] = { 0x0a }; // iClass ACTIVATE_ALL
uint8_t abtAnticol[11];
if ((res = pn53x_initiator_transceive_bytes(pnd, abtReqt, sizeof(abtReqt), NULL, 0, timeout)) < 0) {
if (pn53x_initiator_transceive_bytes(pnd, abtReqt, sizeof(abtReqt), NULL, 0, timeout) < 0) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "got expected timeout on iClass activate all");
//if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout
// continue;
@ -2064,7 +2064,7 @@ static int pn53x_ISO14443A_Barcode_is_present(struct nfc_device *pnd)
}
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
uint8_t abtRxPar[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
if ((ret = nfc_initiator_transceive_bits(pnd, NULL, 0, NULL, abtRx, sizeof(abtRx), abtRxPar)) < 1) {
if (nfc_initiator_transceive_bits(pnd, NULL, 0, NULL, abtRx, sizeof(abtRx), abtRxPar) < 1) {
failures++;
} else {
nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, true);

View file

@ -195,6 +195,8 @@ conf_parse_file(const char *filename,
free(key);
free(value);
} else {
free(key);
free(value);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Parse error on line #%d: %s", lineno, line);
}
}

View file

@ -60,7 +60,9 @@ Thanks to d18c7db and Okko for example code
#include <sys/select.h>
#include <errno.h>
#include <string.h>
#ifdef _MSC_VER
#include <sys/types.h>
#endif
#include <nfc/nfc.h>
#include "nfc-internal.h"

View file

@ -43,7 +43,9 @@ Thanks to d18c7db and Okko for example code
#include <sys/select.h>
#include <errno.h>
#include <string.h>
#ifdef _MSC_VER
#include <sys/types.h>
#endif
#include <nfc/nfc.h>
#include "nfc-internal.h"
@ -817,7 +819,7 @@ pn53x_usb_set_property_bool(nfc_device *pnd, const nfc_property property, const
if (NP_ACTIVATE_FIELD == property) {
/* Switch on/off LED2 and Progressive Field GPIO according to ACTIVATE_FIELD option */
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Switch progressive field %s", bEnable ? "On" : "Off");
if ((res = pn53x_write_register(pnd, PN53X_SFR_P3, _BV(P31) | _BV(P34), bEnable ? _BV(P34) : _BV(P31))) < 0)
if (pn53x_write_register(pnd, PN53X_SFR_P3, _BV(P31) | _BV(P34), bEnable ? _BV(P34) : _BV(P31)) < 0)
return NFC_ECHIP;
}
break;

View file

@ -565,23 +565,27 @@ nfc_initiator_select_passive_target(nfc_device *pnd,
nfc_target *pnt)
{
uint8_t *abtInit = NULL;
uint8_t *abtTmpInit = malloc(MAX(12, szInitData));
uint8_t maxAbt = MAX(12, szInitData);
uint8_t *abtTmpInit = malloc(sizeof(uint8_t) * maxAbt);
size_t szInit = 0;
int res;
if ((res = nfc_device_validate_modulation(pnd, N_INITIATOR, &nm)) != NFC_SUCCESS)
if ((res = nfc_device_validate_modulation(pnd, N_INITIATOR, &nm)) != NFC_SUCCESS) {
free(abtTmpInit);
return res;
}
if (szInitData == 0) {
// Provide default values, if any
prepare_initiator_data(nm, &abtInit, &szInit);
free(abtTmpInit);
} else if (nm.nmt == NMT_ISO14443A) {
abtInit = abtTmpInit;
iso14443_cascade_uid(pbtInitData, szInitData, abtInit, &szInit);
} else {
abtInit = abtTmpInit;
memcpy(abtInit, pbtInitData, szInitData);
free(abtTmpInit);
szInit = szInitData;
}
HAL(initiator_select_passive_target, pnd, nm, abtInit, szInit, pnt);
free(abtTmpInit);