From 925c0711fdb524d2df2ce2dd352cb46d1c8e5de6 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Sun, 19 May 2024 11:18:07 +0200 Subject: [PATCH] lib --- CMakeLists.txt | 9 ++++++--- MyTCPClient.cpp | 6 +++--- MyTCPClient.h | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e796b03..722c04e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,14 +3,17 @@ project(servo_motor) set(CMAKE_CXX_STANDARD 17) -find_package(PkgConfig REQUIRED) find_package(PiPCA9685 REQUIRED) -pkg_check_modules(TCPSocket REQUIRED TCPSocket) + +find_package(Modelec COMPONENTS + TCPClient + REQUIRED +) add_executable(servo_motor MyTCPClient.cpp MyTCPClient.h main.cpp) -target_link_libraries(servo_motor TCPSocket) +target_link_libraries(servo_motor TCPClient) target_link_libraries(servo_motor ${PiPCA9685_LIBRARY}) diff --git a/MyTCPClient.cpp b/MyTCPClient.cpp index f8ddf47..5506240 100644 --- a/MyTCPClient.cpp +++ b/MyTCPClient.cpp @@ -5,7 +5,7 @@ MyTCPClient::MyTCPClient(const char *serverIP, int port) : TCPClient(serverIP, p } void MyTCPClient::handleMessage(const std::string &message) { - std::vector token = TCPSocket::split(message, ";"); + std::vector token = Modelec::split(message, ";"); if (token.size() != 4) { std::cerr << "Message invalide: " << message << std::endl; @@ -57,7 +57,7 @@ void MyTCPClient::handleMessage(const std::string &message) { this->uncheck_panneau(bras); } else if (token[2] == "panneau") { - std::vector args = TCPSocket::split(token[3], ","); + std::vector args = Modelec::split(token[3], ","); int bras = std::stoi(args[0]); int pourcentage = std::stoi(args[1]); @@ -65,7 +65,7 @@ void MyTCPClient::handleMessage(const std::string &message) { this->percentage_panneau(bras, 100 - pourcentage); } else if (token[2] == "angle") { - std::vector args = TCPSocket::split(token[3], ","); + std::vector args = Modelec::split(token[3], ","); if (args.size() != 2) { std::cerr << "Nombre d'arguments invalide" << std::endl; return; diff --git a/MyTCPClient.h b/MyTCPClient.h index 4bd97ff..bb5e14f 100644 --- a/MyTCPClient.h +++ b/MyTCPClient.h @@ -1,7 +1,7 @@ #pragma once -#include "TCPSocket/TCPClient.hpp" -#include "TCPSocket/TCPUtils.hpp" +#include +#include // #include "servo_motor.h" #include