Merge branch 'lostComSupRobManagement'
This commit is contained in:
commit
de767f5f56
3 changed files with 19 additions and 7 deletions
|
@ -131,7 +131,11 @@ int ComRobot::Open(string usart) {
|
||||||
* @return Success if above 0, failure if below 0
|
* @return Success if above 0, failure if below 0
|
||||||
*/
|
*/
|
||||||
int ComRobot::Close() {
|
int ComRobot::Close() {
|
||||||
|
#ifdef __SIMULATION__
|
||||||
|
return close(sock);
|
||||||
|
#elif
|
||||||
return close(fd);
|
return close(fd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,17 +159,22 @@ Message *ComRobot::Write(Message* msg) {
|
||||||
|
|
||||||
char buffer[1024] = {0};
|
char buffer[1024] = {0};
|
||||||
cout << "[" << __PRETTY_FUNCTION__ << "] Send command: " << s << endl << flush;
|
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);
|
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);
|
msgAnswer = new Message(MESSAGE_ANSWER_ROBOT_TIMEOUT);
|
||||||
} else {
|
} else {
|
||||||
string s(&buffer[0], valread);
|
string s(&buffer[0], valread);
|
||||||
msgAnswer = StringToMessage(s);
|
msgAnswer = StringToMessage(s);
|
||||||
//msgAnswer = new Message(MESSAGE_ANSWER_ACK);
|
cout << "Response: " << buffer << ", id: " << msgAnswer->GetID() << endl;
|
||||||
}
|
}
|
||||||
cout << "response: " << buffer << ", id: " << msgAnswer->GetID() << endl;
|
|
||||||
#else
|
#else
|
||||||
AddChecksum(s);
|
AddChecksum(s);
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group>
|
<group>
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.cpp</file>
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.cpp</file>
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
|
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
|
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.h</file>
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.h</file>
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/main.cpp</file>
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/main.cpp</file>
|
||||||
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.h</file>
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.h</file>
|
||||||
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
|
||||||
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
|
||||||
|
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/messages.h</file>
|
||||||
</group>
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
</data>
|
</data>
|
||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group/>
|
<group>
|
||||||
|
<file>file:/home/raphael/Documents/real_time/software/simulateur/main.cpp</file>
|
||||||
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|
Loading…
Reference in a new issue