Skip to content

Commit 96c8ab2

Browse files
committed
Renaming + more robust waits.
1 parent 1e538f8 commit 96c8ab2

6 files changed

Lines changed: 18 additions & 16 deletions

File tree

Common/Cpp/StreamConnections/PollingStreamConnections.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <stddef.h>
1111
#include "StreamInterface.h"
1212

13-
#ifdef PABB2_ENABLE
13+
#ifdef PABB2_FIRMWARE
1414
#include "PabbTime.h"
1515
#else
1616
#include "Common/Cpp/Time.h"

Common/PABotBase2/ReliableConnectionLayer/PABotBase2FW_ReliableStreamConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bool ReliableStreamConnectionFW::run_recv_events(const WallDuration& timeout) no
196196
m_parser.reset();
197197
m_stream_coalescer.reset();
198198
m_stream_coalescer.push_packet(0);
199-
#ifdef PABB2_ENABLE
199+
#ifdef PABB2_FIRMWARE
200200
issue_reset_to_all();
201201
#endif
202202
send_oob_packet_empty(

Common/PABotBase2/ReliableConnectionLayer/PABotBase2FW_ReliableStreamConnection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define PABB2_ReliableConnectionFW_POLL_MS 50
1717
#endif
1818

19-
#ifdef PABB2_ENABLE
19+
#ifdef PABB2_FIRMWARE
2020
#include "PabbTime.h"
2121
#include "LocalMutex.h"
2222
#include "Tools/ResetListener.h"
@@ -32,7 +32,7 @@ namespace PABotBase2{
3232

3333
class ReliableStreamConnectionFW final
3434
: public ReliableStreamConnectionPolling
35-
#ifdef PABB2_ENABLE
35+
#ifdef PABB2_FIRMWARE
3636
, public ResetRunner
3737
#endif
3838
{

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace PokemonAutomation{
3939
#endif
4040

4141
#ifndef PA_VERSION_PATCH
42-
#define PA_VERSION_PATCH 10
42+
#define PA_VERSION_PATCH 11
4343
#endif
4444

4545
const bool IS_BETA_VERSION = PA_IS_BETA;

SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
109109
bool SerialPABotBase2_Connection::open_serial_port(){
110110
{
111111
std::string text = "Opening serial port...";

SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class SerialPABotBase2_Connection final : public PABotBase2::Connection{
3535

3636

3737
private:
38+
void naked_wait(WallDuration duration);
39+
3840
bool open_serial_port();
3941
bool try_connect_to_device(WallDuration timeout);
4042
bool connect_to_device();

0 commit comments

Comments
 (0)