@@ -67,6 +67,7 @@ bool SerialPABotBase2_Connection::cancel(std::exception_ptr exception) noexcept{
6767 if (rts){
6868 rts = false ;
6969 m_unreliable_connection->set_control_state (dtr, rts);
70+ naked_wait (50ms);
7071 Mutex lock;
7172 ConditionVariable cv;
7273 WallClock deadline = current_time () + 50ms;
@@ -77,23 +78,14 @@ bool SerialPABotBase2_Connection::cancel(std::exception_ptr exception) noexcept{
7778 if (!dtr){
7879 dtr = false;
7980 m_unreliable_connection->set_control_state(dtr, rts);
80- Mutex lock;
81- ConditionVariable cv;
82- WallClock deadline = current_time() + 50ms;
83- std::unique_lock<Mutex> lg(lock);
84- cv.wait_until(lg, deadline, [=]{ return current_time() >= deadline; });
81+ naked_wait(50ms);
8582 }
8683#endif
84+ naked_wait (50ms);
8785 }catch (...){
8886// cout << "exception thrown" << endl;
8987 }
9088
91- Mutex lock;
92- ConditionVariable cv;
93- WallClock deadline = current_time () + 50ms;
94- std::unique_lock<Mutex> lg (lock);
95- cv.wait_until (lg, deadline, [=]{ return current_time () >= deadline; });
96-
9789 return false ;
9890}
9991
@@ -106,6 +98,14 @@ ControllerType SerialPABotBase2_Connection::refresh_controller_type(){
10698}
10799
108100
101+
102+ void SerialPABotBase2_Connection::naked_wait (WallDuration duration){
103+ Mutex lock;
104+ ConditionVariable cv;
105+ WallClock deadline = current_time () + duration;
106+ std::unique_lock<Mutex> lg (lock);
107+ cv.wait_until (lg, deadline, [=]{ return current_time () >= deadline; });
108+ }
109109bool SerialPABotBase2_Connection::open_serial_port (){
110110 {
111111 std::string text = " Opening serial port..." ;
0 commit comments