diff --git a/software/raspberry/superviseur-robot/lib/comrobot.cpp b/software/raspberry/superviseur-robot/lib/comrobot.cpp
index cbc618a..cd1c2f8 100644
--- a/software/raspberry/superviseur-robot/lib/comrobot.cpp
+++ b/software/raspberry/superviseur-robot/lib/comrobot.cpp
@@ -131,7 +131,11 @@ int ComRobot::Open(string usart) {
* @return Success if above 0, failure if below 0
*/
int ComRobot::Close() {
+#ifdef __SIMULATION__
+ return close(sock);
+#elif
return close(fd);
+#endif
}
/**
@@ -155,17 +159,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);
diff --git a/software/raspberry/superviseur-robot/nbproject/private/private.xml b/software/raspberry/superviseur-robot/nbproject/private/private.xml
index 80a7712..e6d6c63 100644
--- a/software/raspberry/superviseur-robot/nbproject/private/private.xml
+++ b/software/raspberry/superviseur-robot/nbproject/private/private.xml
@@ -8,11 +8,12 @@
file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.cpp
- file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.cpp
- file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/commonitor.cpp
file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.h
file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/main.cpp
file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.h
+ file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/commonitor.cpp
+ file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.cpp
+ file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/messages.h
diff --git a/software/simulateur/nbproject/private/private.xml b/software/simulateur/nbproject/private/private.xml
index aef7ea3..9b42543 100644
--- a/software/simulateur/nbproject/private/private.xml
+++ b/software/simulateur/nbproject/private/private.xml
@@ -6,6 +6,8 @@
-
+
+ file:/home/raphael/Documents/real_time/software/simulateur/main.cpp
+