add back open com robot semaphore
This commit is contained in:
parent
ebe5dc44de
commit
45ce856660
2 changed files with 9 additions and 4 deletions
|
@ -97,6 +97,10 @@ void Tasks::Init() {
|
|||
cerr << "Error semaphore create sem_serverOk: " << strerror(-err) << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((err = rt_sem_create(&sem_openComRobot, nullptr, 0, S_FIFO))) {
|
||||
cerr << "Error semaphore create sem_openComRobot: " << strerror(-err) << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((err = rt_sem_create(&sem_startRobot, nullptr, 0, S_FIFO))) {
|
||||
cerr << "Error semaphore create sem_startRobot: " << strerror(-err) << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -304,7 +308,7 @@ void Tasks::Join() {
|
|||
rt_sem_v(&sem_stopServer);
|
||||
lostConnection = true;
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
|
||||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
|
||||
rt_sem_v(&sem_openComRobot);
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
|
||||
rt_mutex_acquire(&mutex_watchdogMode, TM_INFINITE);
|
||||
watchdogMode = WITHOUT_WATCHDOG;
|
||||
|
@ -361,7 +365,7 @@ void Tasks::Join() {
|
|||
* *************************************************************************************/
|
||||
while (true) {
|
||||
Message *msgSend;
|
||||
rt_sem_p(&sem_startRobot, TM_INFINITE);
|
||||
rt_sem_p(&sem_openComRobot, TM_INFINITE);
|
||||
cout << "Open serial com (";
|
||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||
status = robot.Open();
|
||||
|
@ -372,6 +376,8 @@ void Tasks::Join() {
|
|||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_NACK)); // msgSend will be deleted by sendToMon
|
||||
} else {
|
||||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK)); // msgSend will be deleted by sendToMon
|
||||
|
||||
rt_sem_p(&sem_startRobot, TM_INFINITE);
|
||||
rt_mutex_acquire(&mutex_watchdogMode, TM_INFINITE);
|
||||
const WatchdogMode mode = watchdogMode;
|
||||
rt_mutex_release(&mutex_watchdogMode);
|
||||
|
@ -430,7 +436,6 @@ void Tasks::Join() {
|
|||
|
||||
while (true) {
|
||||
rt_task_wait_period(nullptr);
|
||||
cout << "Periodic battery level update" << endl;
|
||||
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
rs = robotStarted;
|
||||
|
@ -468,7 +473,6 @@ void Tasks::Join() {
|
|||
|
||||
while (true) {
|
||||
rt_task_wait_period(nullptr);
|
||||
cout << "Periodic movement update" << endl;
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
rs = robotStarted;
|
||||
rt_mutex_release(&mutex_robotStarted);
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
* ********************************************************************/
|
||||
RT_SEM sem_barrier;
|
||||
RT_SEM sem_serverOk;
|
||||
RT_SEM sem_openComRobot;
|
||||
RT_SEM sem_startRobot;
|
||||
RT_SEM sem_stopRobot;
|
||||
RT_SEM sem_stopServer;
|
||||
|
|
Loading…
Reference in a new issue