keep supervisor alive if robot is killed
This commit is contained in:
parent
89a2bae5c0
commit
a87b0ffc69
1 changed files with 9 additions and 4 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue