Merge branch 'lostComSupRobManagement'

This commit is contained in:
Raphael Benistant 2020-03-31 15:11:51 +02:00
commit de767f5f56
3 changed files with 19 additions and 7 deletions

View file

@ -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);

View file

@ -8,11 +8,12 @@
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<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/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/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/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>
</open-files>
</project-private>

View file

@ -6,6 +6,8 @@
</data>
<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">
<group/>
<group>
<file>file:/home/raphael/Documents/real_time/software/simulateur/main.cpp</file>
</group>
</open-files>
</project-private>