From 83a3ee26788c09d6d545a27b0ebecbb0f6c5c47a Mon Sep 17 00:00:00 2001 From: ackimixs Date: Thu, 2 May 2024 11:55:07 +0200 Subject: [PATCH] arduino socket --- TCPServer.cpp | 9 ++++----- TCPServer.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TCPServer.cpp b/TCPServer.cpp index 044d597..87b58e2 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -702,20 +702,19 @@ void TCPServer::goToAruco(const ArucoTag &arucoTag, const int pince) { } void TCPServer::askArduinoPos() { - ClientTCP arduino; for (const auto & client : clients) { if (client.name == "arduino") { - arduino = client; + this->arduinoSocket = client.socket; break; } } - if (arduino.socket == -1) { + if (this->arduinoSocket == -1) { return; } while (!this->_shouldStop) { - this->sendToClient("strat;arduino;get pos;1\n", arduino.socket); + this->sendToClient("strat;arduino;get pos;1\n", this->arduinoSocket); usleep(200'000); } } @@ -727,7 +726,7 @@ void TCPServer::awaitRobotIdle() { // ReSharper disable once CppDFAEndlessLoop while (isRobotIdle < 2) { usleep(100'000); - this->broadcastMessage("strat;arduino;get state;1\n"); + this->sendToClient("strat;arduino;get state;1\n", this->arduinoSocket); timeout++; /*if (timeout > 30) { this->broadcastMessage("strat;arduino;clear;1"); diff --git a/TCPServer.h b/TCPServer.h index 216cec7..2d06186 100644 --- a/TCPServer.h +++ b/TCPServer.h @@ -134,6 +134,7 @@ private: std::thread gameThread; int lidarSocket = -1; + int arduinoSocket = -1; int firstTimeDropWhiteFlower = 0;