From 61b42396d916f6ceea267dcb55e34868526cf662 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Fri, 21 Oct 2016 14:17:23 +0200 Subject: [PATCH 1/2] CMake: allow building of debian packages This patch allows for using the CMakefile to generate debian packages. While CPack is far from perfect for generating debian packages, it is a minimal change and quite helpful for quick deployment on debian based systems. Signed-off-by: Olliver Schinagl --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21ee9e7..cd8183f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ ENDIF(LIBNFC_CONFFILES_MODE) option (BUILD_EXAMPLES "build examples ON/OFF" ON) option (BUILD_UTILS "build utils ON/OFF" ON) +option (BUILD_DEBPKG "build debian package ON/OFF" OFF) + # Doxygen SET(builddir "${CMAKE_BINARY_DIR}") @@ -224,10 +226,14 @@ IF(WIN32) SET(CPACK_GENERATOR "ZIP") ELSE(WIN32) SET(CPACK_GENERATOR "TBZ2") + IF(BUILD_DEBPKG) + SET(CPACK_GENERATOR "DEB") + ENDIF(BUILD_DEBPKG) ENDIF(WIN32) SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library") SET(CPACK_PACKAGE_VENDOR "Roel Verdult") +SET(CPACK_PACKAGE_CONTACT "Roel Verdul ") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "libnfc") From 512be897009cfd9a4213e1bd1093845780a31005 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Fri, 21 Oct 2016 13:46:26 +0200 Subject: [PATCH 2/2] busses: i2c: improve logging Currently we only inform the user with the error logging mechanism that we received a different number of bytes than expected. Thus in case of an error, we say that we sent/received -1 bytes. However -1 indicates an error and errno is set to indicate the error state. This patch extends the logging to also print the actual error. Additionally the same debugging printing was added to read, which is now silently returned to the caller. Signed-off-by: Olliver Schinagl --- libnfc/buses/i2c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libnfc/buses/i2c.c b/libnfc/buses/i2c.c index a0ee189..a37372d 100644 --- a/libnfc/buses/i2c.c +++ b/libnfc/buses/i2c.c @@ -135,6 +135,8 @@ i2c_read(i2c_device id, uint8_t *pbtRx, const size_t szRx) if (recCount < 0) { res = NFC_EIO; + log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, + "Error: read only %d bytes (%d expected) (%s).", (int)recCount, (int) szRx, strerror(errno)); } else { if (recCount < (ssize_t)szRx) { res = NFC_EINVARG; @@ -167,7 +169,7 @@ i2c_write(i2c_device id, const uint8_t *pbtTx, const size_t szTx) return NFC_SUCCESS; } else { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, - "Error: wrote only %d bytes (%d expected).", (int)writeCount, (int) szTx); + "Error: wrote only %d bytes (%d expected) (%s).", (int)writeCount, (int) szTx, strerror(errno)); return NFC_EIO; } }