From f974891d97389fd0dd1b3210169ecc111275b00f Mon Sep 17 00:00:00 2001 From: Anthony Mallet <anthony.mallet@laas.fr> Date: Fri, 8 Dec 2017 19:07:13 +0100 Subject: [PATCH] [wip/FRILibrary] Don't require CAP_SYS_NICE and compile with -fPIC to objects * patch-aj and patch-ak prevent the software from miserably failing when a user does not have CAP_SYS_NICE. This is merely required to set the scheduling parameters of threads, and this should not be fatal. Just print a warning instead. * update patch-ai to compile object files with -fPIC. This won't hurt when linked in an executable, and it is required whenb link this library in a another shared library. * Fix unzip extraction by forcing -aa, so that CR/LF is converted correctly. Updated all patches accordingly Fixes #140, bump PKGREVISION --- FRILibrary/Makefile | 4 ++++ FRILibrary/distinfo | 20 ++++++++++--------- FRILibrary/patches/patch-aa | 12 ++++++------ FRILibrary/patches/patch-ab | 16 ++++++++-------- FRILibrary/patches/patch-ac | 16 ++++++++-------- FRILibrary/patches/patch-ad | 16 ++++++++-------- FRILibrary/patches/patch-ae | 16 ++++++++-------- FRILibrary/patches/patch-af | 16 ++++++++-------- FRILibrary/patches/patch-ag | 28 +++++++++++++-------------- FRILibrary/patches/patch-ah | 16 ++++++++-------- FRILibrary/patches/patch-ai | 36 ++++++++++++++++++----------------- FRILibrary/patches/patch-aj | 38 +++++++++++++++++++++++++++++++++++++ FRILibrary/patches/patch-ak | 24 +++++++++++++++++++++++ 13 files changed, 164 insertions(+), 94 deletions(-) create mode 100644 FRILibrary/patches/patch-aj create mode 100644 FRILibrary/patches/patch-ak diff --git a/FRILibrary/Makefile b/FRILibrary/Makefile index 5f8fd4ff..2b60ba14 100644 --- a/FRILibrary/Makefile +++ b/FRILibrary/Makefile @@ -2,6 +2,7 @@ # Created: Matthieu Herrb on Mon, 23 May 2016 # +PKGREVISION= 1 DISTNAME= fril VERSION= 1.2 PKGNAME= FRILibrary-${VERSION} @@ -15,6 +16,9 @@ MAINTAINER= openrobots@laas.fr COMMENT= C++ Library to interface the KUKA Light Weight Robot IV LICENSE= apache-2.0 +# force text conversion to handle CR/LR correctly. +EXTRACT_OPTS_ZIP=-aao + WRKSRC= ${WRKDIR}/FRILibrary BUILD_DIRS= Linux diff --git a/FRILibrary/distinfo b/FRILibrary/distinfo index 61e34be8..1f4d96ce 100644 --- a/FRILibrary/distinfo +++ b/FRILibrary/distinfo @@ -1,12 +1,14 @@ SHA1 (frilib-1.2/fril.zip) = a876c225b464ffa25a0dcbae8783eb84e5d06132 RMD160 (frilib-1.2/fril.zip) = b23957503feee5c16e610eb4fae65d49760fcdc2 Size (frilib-1.2/fril.zip) = 997218 bytes -SHA1 (patch-aa) = 5922a171eecc767859b565cd01c00b94fc0a3321 -SHA1 (patch-ab) = 7313d58b0a215b7b6ddb84c9b0187191f300fe7e -SHA1 (patch-ac) = 451b9b1e8c534747af7f75bbc894ac6d81450fbf -SHA1 (patch-ad) = c5b88b1b2ed9605d0ddff59e06b400d7af398c76 -SHA1 (patch-ae) = 2540ae5fe484aaa59b610b7bcd74659bec1f2bbb -SHA1 (patch-af) = 8c230783e5ffcaf8194738ab371a32485eef892b -SHA1 (patch-ag) = 34c2a6973f17861182555f3c295732685730c36f -SHA1 (patch-ah) = 4379946c9efaae50f9935ccd6d4acdfb6e5840c6 -SHA1 (patch-ai) = 02d8aaee1583ff4da2c81ae4673bd70181afd4ae +SHA1 (patch-aa) = 116b579954eafecc5c3e611199fffe80dd9d8c37 +SHA1 (patch-ab) = df3ad8dec088eb66624e5180647faccbde6b5614 +SHA1 (patch-ac) = 408cc7be2429ad59bc8c311fa312a169730e062f +SHA1 (patch-ad) = 08edc24d746782cd15445e94357acba58c80aafb +SHA1 (patch-ae) = 1fe3dcba29eab2f7b83de4aad76fc7cb7976c475 +SHA1 (patch-af) = f25d28021ffd688e82a1bca3140d1376124fdff1 +SHA1 (patch-ag) = 7de00937cd7d3b3c290af9900f9fa8ed79985a72 +SHA1 (patch-ah) = 7ceb00185ea5e4395d7e7a611b3d9b586561bb27 +SHA1 (patch-ai) = 3e35976bc8dca9b70249849c87ffe7bfc1eb11b9 +SHA1 (patch-aj) = 406ad55706a7e7d04873998a08e374c31e56157a +SHA1 (patch-ak) = 82e6c7dc56b46dc00ddca5d30b1e5fdc77b93d93 diff --git a/FRILibrary/patches/patch-aa b/FRILibrary/patches/patch-aa index 279537d6..0d2a5de2 100644 --- a/FRILibrary/patches/patch-aa +++ b/FRILibrary/patches/patch-aa @@ -1,11 +1,11 @@ --- ./etc/980039-FRI-Driver.init.orig 2011-11-19 21:07:18.000000000 +0100 +++ ./etc/980039-FRI-Driver.init 2016-05-23 17:57:02.808782000 +0200 @@ -16,5 +16,5 @@ - - [Logging] - NumberOfLoggingFileEntries=60000 --LoggingPath=/home/lwrcontrol/output + + [Logging] + NumberOfLoggingFileEntries=60000 +-LoggingPath=/home/lwrcontrol/output -LoggingFileName=LWR-Scope.dat \ No newline at end of file -+LoggingPath=/tmp -+LoggingFileName=LWR-Scope.dat ++LoggingPath=/tmp ++LoggingFileName=LWR-Scope.dat diff --git a/FRILibrary/patches/patch-ab b/FRILibrary/patches/patch-ab index a6b2cb9b..1bd649c2 100644 --- a/FRILibrary/patches/patch-ab +++ b/FRILibrary/patches/patch-ab @@ -1,11 +1,11 @@ --- ./src/FastResearchInterfaceTest/FastResearchInterfaceTest.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/FastResearchInterfaceTest/FastResearchInterfaceTest.cpp 2016-05-23 17:53:38.860953000 +0200 @@ -108,7 +108,7 @@ - #ifdef __LINUX__ - fprintf(stdout, "You may need superuser permission to run this program.\n"); - fflush(stdout); -- FRI = new FastResearchInterface("/home/torsten/etc/980039-FRI-Driver.init"); -+ FRI = new FastResearchInterface(PREFIX "/etc/980039-FRI-Driver.init"); - #endif - - #ifdef __MACOS__ + #ifdef __LINUX__ + fprintf(stdout, "You may need superuser permission to run this program.\n"); + fflush(stdout); +- FRI = new FastResearchInterface("/home/torsten/etc/980039-FRI-Driver.init"); ++ FRI = new FastResearchInterface(PREFIX "/etc/980039-FRI-Driver.init"); + #endif + + #ifdef __MACOS__ diff --git a/FRILibrary/patches/patch-ac b/FRILibrary/patches/patch-ac index 1ad5de85..142a14fd 100644 --- a/FRILibrary/patches/patch-ac +++ b/FRILibrary/patches/patch-ac @@ -1,11 +1,11 @@ --- ./src/LWRGettingStartedExamples/LWRCartImpedanceControlExample.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/LWRGettingStartedExamples/LWRCartImpedanceControlExample.cpp 2016-05-23 17:54:55.458384000 +0200 @@ -91,7 +91,7 @@ - - LWRCartImpedanceController *Robot; - -- Robot = new LWRCartImpedanceController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); -+ Robot = new LWRCartImpedanceController(PREFIX "/etc/980039-FRI-Driver.init"); - - fprintf(stdout, "RobotCartImpedanceController object created. Starting the robot...\n"); - + + LWRCartImpedanceController *Robot; + +- Robot = new LWRCartImpedanceController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); ++ Robot = new LWRCartImpedanceController(PREFIX "/etc/980039-FRI-Driver.init"); + + fprintf(stdout, "RobotCartImpedanceController object created. Starting the robot...\n"); + diff --git a/FRILibrary/patches/patch-ad b/FRILibrary/patches/patch-ad index 7f548fa2..c2305880 100644 --- a/FRILibrary/patches/patch-ad +++ b/FRILibrary/patches/patch-ad @@ -1,11 +1,11 @@ --- ./src/LWRGettingStartedExamples/LWRJointImpedanceControlExample.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/LWRGettingStartedExamples/LWRJointImpedanceControlExample.cpp 2016-05-23 18:56:00.196563000 +0200 @@ -81,7 +81,7 @@ - - LWRJointImpedanceController *Robot; - -- Robot = new LWRJointImpedanceController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); -+ Robot = new LWRJointImpedanceController(PREFIX "/etc/980039-FRI-Driver.init"); - - fprintf(stdout, "RobotJointImpedanceController object created. Starting the robot...\n"); - + + LWRJointImpedanceController *Robot; + +- Robot = new LWRJointImpedanceController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); ++ Robot = new LWRJointImpedanceController(PREFIX "/etc/980039-FRI-Driver.init"); + + fprintf(stdout, "RobotJointImpedanceController object created. Starting the robot...\n"); + diff --git a/FRILibrary/patches/patch-ae b/FRILibrary/patches/patch-ae index d6040272..5dbf3701 100644 --- a/FRILibrary/patches/patch-ae +++ b/FRILibrary/patches/patch-ae @@ -1,11 +1,11 @@ --- ./src/LWRGettingStartedExamples/LWRJointPositionControlExample.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/LWRGettingStartedExamples/LWRJointPositionControlExample.cpp 2016-05-23 17:55:43.250402000 +0200 @@ -81,7 +81,7 @@ - - LWRJointPositionController *Robot; - -- Robot = new LWRJointPositionController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); -+ Robot = new LWRJointPositionController(PREFIX "/etc/980039-FRI-Driver.init"); - - fprintf(stdout, "RobotJointPositionController object created. Starting the robot...\n"); - + + LWRJointPositionController *Robot; + +- Robot = new LWRJointPositionController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); ++ Robot = new LWRJointPositionController(PREFIX "/etc/980039-FRI-Driver.init"); + + fprintf(stdout, "RobotJointPositionController object created. Starting the robot...\n"); + diff --git a/FRILibrary/patches/patch-af b/FRILibrary/patches/patch-af index 97ce4c56..9e2d6d31 100644 --- a/FRILibrary/patches/patch-af +++ b/FRILibrary/patches/patch-af @@ -1,11 +1,11 @@ --- ./src/LWRGettingStartedExamples/LWRLoggingExample.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/LWRGettingStartedExamples/LWRLoggingExample.cpp 2016-05-23 17:56:15.514740000 +0200 @@ -87,7 +87,7 @@ - - LWRJointPositionController *Robot; - -- Robot = new LWRJointPositionController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); -+ Robot = new LWRJointPositionController(PREFIX "/etc/980039-FRI-Driver.init"); - - fprintf(stdout, "RobotJointPositionController object created. Starting the robot...\n"); - + + LWRJointPositionController *Robot; + +- Robot = new LWRJointPositionController("/home/lwrcontrol/etc/980039-FRI-Driver.init"); ++ Robot = new LWRJointPositionController(PREFIX "/etc/980039-FRI-Driver.init"); + + fprintf(stdout, "RobotJointPositionController object created. Starting the robot...\n"); + diff --git a/FRILibrary/patches/patch-ag b/FRILibrary/patches/patch-ag index fdd3e9db..f6c19b19 100644 --- a/FRILibrary/patches/patch-ag +++ b/FRILibrary/patches/patch-ag @@ -1,17 +1,17 @@ --- ./src/FastResearchInterfaceLibrary/FastResearchInterface.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/FastResearchInterfaceLibrary/FastResearchInterface.cpp 2016-05-23 18:26:01.337261000 +0200 @@ -240,12 +240,12 @@ - } - else - { -- sprintf(this->LoggingPath, ".%s\0", OS_FOLDER_SEPARATOR); -+ sprintf(this->LoggingPath, ".%s", OS_FOLDER_SEPARATOR); - } - - if (strlen(this->LoggingFileName) == 0) - { -- sprintf(this->LoggingFileName, "FRI.dat\0"); -+ sprintf(this->LoggingFileName, "FRI.dat"); - } - - this->DataLogger = new DataLogging( this->RobotName + } + else + { +- sprintf(this->LoggingPath, ".%s\0", OS_FOLDER_SEPARATOR); ++ sprintf(this->LoggingPath, ".%s", OS_FOLDER_SEPARATOR); + } + + if (strlen(this->LoggingFileName) == 0) + { +- sprintf(this->LoggingFileName, "FRI.dat\0"); ++ sprintf(this->LoggingFileName, "FRI.dat"); + } + + this->DataLogger = new DataLogging( this->RobotName diff --git a/FRILibrary/patches/patch-ah b/FRILibrary/patches/patch-ah index 2b951801..344f64db 100644 --- a/FRILibrary/patches/patch-ah +++ b/FRILibrary/patches/patch-ah @@ -1,11 +1,11 @@ --- ./src/FastResearchInterfaceLibrary/UDPSocket.cpp.orig 2014-12-03 09:27:36.000000000 +0100 +++ ./src/FastResearchInterfaceLibrary/UDPSocket.cpp 2016-05-23 18:27:33.082396000 +0200 @@ -157,7 +157,7 @@ - } - else - { -- fprintf(stderr, "ERROR: Data size incorrect (received: %d, expected %d)\n", DataReceived, sizeof(FRIDataReceivedFromKRC)); -+ fprintf(stderr, "ERROR: Data size incorrect (received: %d, expected %zu)\n", DataReceived, sizeof(FRIDataReceivedFromKRC)); - fflush(stderr); - } - } + } + else + { +- fprintf(stderr, "ERROR: Data size incorrect (received: %d, expected %d)\n", DataReceived, sizeof(FRIDataReceivedFromKRC)); ++ fprintf(stderr, "ERROR: Data size incorrect (received: %d, expected %zu)\n", DataReceived, sizeof(FRIDataReceivedFromKRC)); + fflush(stderr); + } + } diff --git a/FRILibrary/patches/patch-ai b/FRILibrary/patches/patch-ai index a14b2618..5dfbf4f4 100644 --- a/FRILibrary/patches/patch-ai +++ b/FRILibrary/patches/patch-ai @@ -1,19 +1,21 @@ + * Generate PIC library, so that this can be linked in shared libraries + * Pass PREFIX to avoid hardcoding paths + --- Linux/Makefile.global.orig 2013-10-30 09:28:32.000000000 +0100 +++ Linux/Makefile.global 2016-05-23 18:47:54.687506000 +0200 -@@ -80,13 +80,14 @@ - DEBUG_EXE_DIR=debug/bin - DEBUG_OBJ_DIR=debug/obj - DEBUG_LIB_DIR=debug/lib --DEBUG_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -ggdb -+DEBUG_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -ggdb -DPREFIX=\"${PREFIX}\" -+ - DEBUG_CL= g++ $(SYSTEM_LIBS) -gddb - - RELEASE_EXE_DIR=release/bin - RELEASE_OBJ_DIR=release/obj - RELEASE_LIB_DIR=release/lib --RELEASE_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -O3 -+RELEASE_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -O3 -DPREFIX=\"${PREFIX}\" - RELEASE_CL= g++ $(SYSTEM_LIBS) - - AR= ar vrs +@@ -80,13 +80,13 @@ + DEBUG_EXE_DIR=debug/bin + DEBUG_OBJ_DIR=debug/obj + DEBUG_LIB_DIR=debug/lib +-DEBUG_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -ggdb ++DEBUG_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -ggdb -fPIC -DPREFIX=\"${PREFIX}\" + DEBUG_CL= g++ $(SYSTEM_LIBS) -gddb + + RELEASE_EXE_DIR=release/bin + RELEASE_OBJ_DIR=release/obj + RELEASE_LIB_DIR=release/lib +-RELEASE_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -O3 ++RELEASE_CC= g++ -c -I $(INCLUDE_DIR) -D$(TARGET_OS) -O3 -fPIC -DPREFIX=\"${PREFIX}\" + RELEASE_CL= g++ $(SYSTEM_LIBS) + + AR= ar vrs diff --git a/FRILibrary/patches/patch-aj b/FRILibrary/patches/patch-aj new file mode 100644 index 00000000..9891b73a --- /dev/null +++ b/FRILibrary/patches/patch-aj @@ -0,0 +1,38 @@ +Don't fail to create pthread if user don't have CAP_SYS_NICE + +--- src/FastResearchInterfaceLibrary/FastResearchInterface.cpp~ 2017-12-08 16:40:08.568668402 +0100 ++++ src/FastResearchInterfaceLibrary/FastResearchInterface.cpp 2017-12-08 18:40:03.925198913 +0100 +@@ -155,15 +155,12 @@ + + // Set the thread scheduling policy attribute to round robin + // default is OTHER which equals RR in QNX 6.5.0. +- pthread_attr_setschedpolicy(&AttributesKRCCommunicationThread , SCHED_FIFO ) ; + pthread_attr_setschedpolicy(&AttributesTimerThread , SCHED_FIFO ) ; + + // Set the thread's inherit-scheduling attribute to explicit + // otherwise, the scheduling parameters Cannot be changed (e.g., priority) +- pthread_attr_setinheritsched(&AttributesKRCCommunicationThread , PTHREAD_EXPLICIT_SCHED ) ; + pthread_attr_setinheritsched(&AttributesTimerThread , PTHREAD_EXPLICIT_SCHED ) ; + +- pthread_attr_setschedparam(&AttributesKRCCommunicationThread , &SchedulingParamsKRCCommunicationThread ) ; + pthread_attr_setschedparam(&AttributesTimerThread , &SchedulingParamsTimerThread ) ; + + // this is supposed to become the message thread +@@ -229,7 +226,16 @@ + } + + ThreadCreated = false; +- pthread_mutex_unlock(&(this->MutexForThreadCreation)); ++ ++ if (pthread_setschedparam(KRCCommunicationThread, SCHED_FIFO, ++ &SchedulingParamsKRCCommunicationThread)) { ++ if (errno == EPERM) { ++ this->OutputConsole->printf("Warning: not enough privilege " ++ "to set scheduling parameters\n"); ++ } ++ } ++ ++ pthread_mutex_unlock(&(this->MutexForThreadCreation)); + + if (strlen(this->LoggingPath) > 0) + { diff --git a/FRILibrary/patches/patch-ak b/FRILibrary/patches/patch-ak new file mode 100644 index 00000000..0a4b7145 --- /dev/null +++ b/FRILibrary/patches/patch-ak @@ -0,0 +1,24 @@ +Don't fail to create pthread if user don't have CAP_SYS_NICE + +--- src/FastResearchInterfaceLibrary/Console.cpp~ 2014-12-03 09:27:36.000000000 +0100 ++++ src/FastResearchInterfaceLibrary/Console.cpp 2017-12-08 18:41:56.650521057 +0100 +@@ -81,9 +81,6 @@ + ThreadSchedulingParams.sched_priority = Priority; + + pthread_attr_init (&ThreadAttributes ) ; +- pthread_attr_setschedpolicy (&ThreadAttributes , SCHED_FIFO ) ; +- pthread_attr_setinheritsched(&ThreadAttributes , PTHREAD_EXPLICIT_SCHED ) ; +- pthread_attr_setschedparam (&ThreadAttributes , &ThreadSchedulingParams ) ; + + pthread_create( &ConsoleThread + , &ThreadAttributes +@@ -97,6 +94,9 @@ + pthread_cond_wait (&(this->CondVar), &(this->Mutex)); + } + ++ pthread_setschedparam(ConsoleThread, SCHED_FIFO, ++ &ThreadSchedulingParams); ++ + pthread_mutex_unlock(&(this->Mutex)); + + memset(this->Buffer, 0x0, 2 -- GitLab