mirror of
https://github.com/modelec/servo_moteurs.git
synced 2026-03-18 21:40:31 +01:00
lib
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user