This commit is contained in:
ackimixs
2024-05-19 11:18:07 +02:00
parent 4cbc352eb6
commit 925c0711fd
3 changed files with 11 additions and 8 deletions

View File

@@ -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})

View File

@@ -5,7 +5,7 @@ MyTCPClient::MyTCPClient(const char *serverIP, int port) : TCPClient(serverIP, p
}
void MyTCPClient::handleMessage(const std::string &message) {
std::vector<std::string> token = TCPSocket::split(message, ";");
std::vector<std::string> 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<std::string> args = TCPSocket::split(token[3], ",");
std::vector<std::string> 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<std::string> args = TCPSocket::split(token[3], ",");
std::vector<std::string> args = Modelec::split(token[3], ",");
if (args.size() != 2) {
std::cerr << "Nombre d'arguments invalide" << std::endl;
return;

View File

@@ -1,7 +1,7 @@
#pragma once
#include "TCPSocket/TCPClient.hpp"
#include "TCPSocket/TCPUtils.hpp"
#include <Modelec/TCPClient.h>
#include <Modelec/Utils.h>
// #include "servo_motor.h"
#include <PiPCA9685/PCA9685.h>