diff --git a/software/raspberry/superviseur-robot/lib/comrobot.cpp b/software/raspberry/superviseur-robot/lib/comrobot.cpp index cbc618a..904f0ba 100644 --- a/software/raspberry/superviseur-robot/lib/comrobot.cpp +++ b/software/raspberry/superviseur-robot/lib/comrobot.cpp @@ -155,17 +155,22 @@ Message *ComRobot::Write(Message* msg) { char buffer[1024] = {0}; cout << "[" << __PRETTY_FUNCTION__ << "] Send command: " << s << endl << flush; - send(sock, s.c_str(), s.length(), 0); + send(sock, s.c_str(), s.length(), MSG_NOSIGNAL); int valread = read(sock, buffer, 1024); - if (valread < 0) { + + if (valread == 0) { + cout << "The communication is out of order" << endl; + msgAnswer = new Message(MESSAGE_ANSWER_COM_ERROR); + } else if (valread < 0) { + cout << "Timeout" << endl; msgAnswer = new Message(MESSAGE_ANSWER_ROBOT_TIMEOUT); } else { string s(&buffer[0], valread); msgAnswer = StringToMessage(s); - //msgAnswer = new Message(MESSAGE_ANSWER_ACK); + cout << "Response: " << buffer << ", id: " << msgAnswer->GetID() << endl; } - cout << "response: " << buffer << ", id: " << msgAnswer->GetID() << endl; + #else AddChecksum(s);