 
 Signed-off-by: Martin Jansa <martin.jansa@lge.com>
 ---
- CMakeLists.txt                                | 36 +-----------
- cmake/libphidget22-extras.cmake.in            |  4 +-
- ...ts22-fix-uninitialized-memory-access.patch | 56 -------------------
- 3 files changed, 3 insertions(+), 93 deletions(-)
- delete mode 100644 patch/libphidgets22-fix-uninitialized-memory-access.patch
+ CMakeLists.txt                                |  37 +--
+ cmake/libphidget22-extras.cmake.in            |   4 +-
+ ...phidgets22-1.6.20200417-fix-warnings.patch | 260 ------------------
+ 3 files changed, 3 insertions(+), 298 deletions(-)
+ delete mode 100644 patch/libphidgets22-1.6.20200417-fix-warnings.patch
 
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index c19ed20..706e59a 100644
+index 462ee7f..706e59a 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -3,40 +3,6 @@ project(libphidget22)
+@@ -3,41 +3,6 @@ project(libphidget22)
  
  find_package(ament_cmake REQUIRED)
  
--set(extra_c_flags "-g -O2 -Wno-incompatible-pointer-types -Wno-deprecated-declarations -Wno-format-truncation")
+-set(extra_c_flags "-g -O2 -Wno-incompatible-pointer-types -Wno-deprecated-declarations -Wno-format-truncation -fPIC")
 -
 -include(ExternalProject)
 -ExternalProject_Add(EP_${PROJECT_NAME}
--    URL https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22/libphidget22-1.4.20190605.tar.gz
--    URL_MD5 96e5d64263866d34e1d9a5f4ba78ba65
--
--    PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patch/libphidgets22-fix-uninitialized-memory-access.patch
+-    URL https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22/libphidget22-1.6.20200417.tar.gz
+-    URL_MD5 f8c85f8348ddc0fb46146c0d9d8f884e
+-
+-    PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patch/libphidgets22-1.6.20200417-fix-warnings.patch
 -    SOURCE_DIR ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-src
 -    CONFIGURE_COMMAND
 -      <SOURCE_DIR>/configure
 -      CFLAGS=${extra_c_flags}
 -      --prefix=${CMAKE_CURRENT_BINARY_DIR}/libphidget22_install
+-      --disable-ldconfig
 -    BUILD_COMMAND $(MAKE)
 -    INSTALL_COMMAND $(MAKE) install
 -)

-list(APPEND @PROJECT_NAME@_LIBRARIES "${@PROJECT_NAME@_DIR}/../../../opt/libphidget22/lib/libphidget22.so")
+list(APPEND @PROJECT_NAME@_INCLUDE_DIRS "${@PROJECT_NAME@_DIR}/../../../../usr/include")
+list(APPEND @PROJECT_NAME@_LIBRARIES "${@PROJECT_NAME@_DIR}/../../../../usr/lib/libphidget22.so")
diff --git a/patch/libphidgets22-fix-uninitialized-memory-access.patch b/patch/libphidgets22-fix-uninitialized-memory-access.patch
deleted file mode 100644
index 60817ac..0000000
--- a/patch/libphidgets22-fix-uninitialized-memory-access.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-diff -urp libphidget22-1.4.20190605.orig/src/plat/linux/usblinux.c libphidget22-1.4.20190605/src/plat/linux/usblinux.c
---- libphidget22-1.4.20190605.orig/src/plat/linux/usblinux.c	2019-06-05 16:06:29.000000000 -0400
-+++ libphidget22-1.4.20190605/src/plat/linux/usblinux.c	2019-07-18 09:35:23.566476582 -0400
-@@ -62,11 +62,12 @@ static libusb_context *libusbContext;
- static void
- logBuffer(unsigned char *data, int dataLen, const char *message) {
- 	Phidget_LogLevel ll;
-+	PhidgetReturnCode ret;
- 	char str[2000];
- 	int i, j;
- 
--	PhidgetLog_getSourceLevel("phidget22usb", &ll);
--	if (ll != PHIDGET_LOG_VERBOSE)
-+	ret = PhidgetLog_getSourceLevel("phidget22usb", &ll);
-+	if (ret != EPHIDGET_OK || ll != PHIDGET_LOG_VERBOSE)
- 		return;
- 
- 	str[0]='\0';
-diff -Nurp libphidget22-1.4.20190605.orig/src/vintpackets.c libphidget22-1.4.20190605/src/vintpackets.c
---- libphidget22-1.4.20190605.orig/src/vintpackets.c	2019-06-05 20:06:22.000000000 +0000
-+++ libphidget22-1.4.20190605/src/vintpackets.c	2019-08-06 16:43:45.856531653 +0000
-@@ -2783,7 +2783,7 @@ sendLCD1100_WRITEBITMAP(PhidgetChannelHa
- 	unsigned char bit;
- 	uint8_t buf[48];
- 	const uint8_t *bitmap;
--	int count;
-+	int count = 0;
- 	int xsize;
- 	int ysize;
- 	int x;
-diff -Nurp libphidget22-1.4.20190605.orig/src/class/distancesensor.gen.c libphidget22-1.4.20190605/src/class/distancesensor.gen.c
---- libphidget22-1.4.20190605.orig/src/class/distancesensor.gen.c	2019-06-05 20:06:28.000000000 +0000
-+++ libphidget22-1.4.20190605/src/class/distancesensor.gen.c	2019-08-06 16:51:37.053708754 +0000
-@@ -228,8 +228,8 @@ _initAfterOpen(PhidgetChannelHandle phid
- 		MOS_PANIC("Unsupported Channel");
- 	}

- 	ch->count = 0;
- 
- 	return (ret);
-diff -urp libphidget22-1.6.20200417.orig/src/device/dataadapterdevice.c libphidget22-1.6.20200417/src/device/dataadapterdevice.c
---- libphidget22-1.6.20200417.orig/src/device/dataadapterdevice.c	2020-04-17 21:50:41.000000000 +0000
-+++ libphidget22-1.6.20200417/src/device/dataadapterdevice.c	2020-06-02 13:28:12.385198805 +0000
-@@ -699,25 +699,3 @@ PhidgetReturnCode sendDataBuffer(Phidget
- 	}
- 	return ret;
- }
--
--
--//CRC16 function found from https://ctlsys.com/support/how_to_compute_the_modbus_rtu_message_crc/
--// Compute the MODBUS RTU CRC
--uint16_t ModRTU_CRC(uint8_t *buf, uint16_t len)
--{
--	uint16_t crc = 0xFFFF;
--
--	for (uint16_t pos = 0; pos < len; pos++) {
--		crc ^= (uint16_t)buf[pos];          // XOR byte into least sig. byte of crc
--
--		for (int i = 8; i != 0; i--) {    // Loop over each bit
--			if ((crc & 0x0001) != 0) {      // If the LSB is set
--				crc >>= 1;                    // Shift right and XOR 0xA001
--				crc ^= 0xA001;
--			} else                            // Else LSB is not set
--				crc >>= 1;                    // Just shift right
--		}
--	}
--	// Note, this number has low and high bytes swapped, so use it accordingly (or swap bytes)
--	return crc;
--}
-diff -urp libphidget22-1.6.20200417.orig/src/device/genericdevice.c libphidget22-1.6.20200417/src/device/genericdevice.c
---- libphidget22-1.6.20200417.orig/src/device/genericdevice.c	2020-04-17 21:50:41.000000000 +0000
-+++ libphidget22-1.6.20200417/src/device/genericdevice.c	2020-06-02 13:28:50.317025565 +0000
-@@ -104,7 +104,7 @@ PhidgetGenericDevice_bridgeInput(Phidget
- 		case PHIDUID_GENERIC_PHIDUSB:
- 			len = getBridgePacketArrayLen(bp, 2);
- 
--			if (len > (int)phid->OUTPacketLength[0])
-+			if (len > (size_t)phid->OUTPacketLength[0])
- 				return (EPHIDGET_INVALIDARG);
- 
- 			return (PhidgetDevice_transferpacket(bp->iop, (PhidgetDeviceHandle)phid, PHIDGETUSB_REQ_CHANNEL_WRITE,
-@@ -120,7 +120,7 @@ PhidgetGenericDevice_bridgeInput(Phidget
- 		case PHIDUID_GENERIC_PHIDUSB:
- 			len = getBridgePacketArrayLen(bp, 1);
- 
--			if (len > (int)phid->OUTPacketLength[0])
-+			if (len > (size_t)phid->OUTPacketLength[0])
- 				return (EPHIDGET_INVALIDARG);
- 
- 			return (PhidgetDevice_transferpacket(bp->iop, (PhidgetDeviceHandle)phid, PHIDGETUSB_REQ_DEVICE_WRITE,
-@@ -136,8 +136,8 @@ PhidgetGenericDevice_bridgeInput(Phidget
- 		case PHIDUID_GENERIC_PHIDUSB:
- 			len = getBridgePacketInt32(bp, 2);
- 
--			if (len > (int)phid->OUTPacketLength[0])
--				len = (int)phid->OUTPacketLength[0];
-+			if (len > (size_t)phid->OUTPacketLength[0])
-+				len = (size_t)phid->OUTPacketLength[0];
- 
- 			ret = PhidgetDevice_transferpacket(bp->iop, (PhidgetDeviceHandle)phid, PHIDGETUSB_REQ_CHANNEL_READ,
- 				getBridgePacketInt32(bp, 0), getBridgePacketInt32(bp, 1),
-@@ -170,8 +170,8 @@ PhidgetGenericDevice_bridgeInput(Phidget
- 		case PHIDUID_GENERIC_PHIDUSB:
- 			len = getBridgePacketInt32(bp, 1);
- 
--			if (len > (int)phid->OUTPacketLength[0])
--				len = (int)phid->OUTPacketLength[0];
-+			if (len > (size_t)phid->OUTPacketLength[0])
-+				len = (size_t)phid->OUTPacketLength[0];
- 
- 			ret = PhidgetDevice_transferpacket(bp->iop, (PhidgetDeviceHandle)phid, PHIDGETUSB_REQ_DEVICE_READ,
- 				getBridgePacketInt32(bp, 0), 0,
-diff -urp libphidget22-1.6.20200417.orig/src/phidget.c libphidget22-1.6.20200417/src/phidget.c
---- libphidget22-1.6.20200417.orig/src/phidget.c	2020-04-17 21:50:39.000000000 +0000
-+++ libphidget22-1.6.20200417/src/phidget.c	2020-06-02 13:30:49.607480749 +0000
-@@ -2317,7 +2317,7 @@ createPhidgetHIDUSBDevice(const PhidgetU
- #ifdef _WINDOWS
- 	wcsncpy(conn->DevicePath, (const wchar_t *)devpath, MAX_PATH);
- #elif defined(_LINUX) || defined(_FREEBSD) && !defined(_ANDROID)
--	strncpy(conn->uniqueName, (const char *)devpath, 20);
-+	strncpy(conn->uniqueName, (const char *)devpath, 19);
- #endif
- #if defined(_ANDROID)
- 	mos_strncpy(conn->dev, (const char *)devpath, sizeof(conn->dev));
-@@ -2348,7 +2348,7 @@ createPhidgetPHIDUSBDevice(const Phidget
- #ifdef _WINDOWS
- 	wcsncpy(conn->DevicePath, (const wchar_t *)devpath, MAX_PATH);
- #elif defined(_LINUX) || defined(_FREEBSD) && !defined(_ANDROID)
--	strncpy(conn->uniqueName, (const char *)devpath, 20);
-+	strncpy(conn->uniqueName, (const char *)devpath, 19);
- #endif
- #if defined(_ANDROID)
- 	mos_strncpy(conn->dev, (const char *)devpath, sizeof(conn->dev));
