Skip to content

Commit 9365924

Browse files
committed
Fix controller error behavior. Make unknown program ID versioning work.
1 parent 51883c1 commit 9365924

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

SerialPrograms/Source/Controllers/ControllerSession.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ std::string ControllerSession::reset(bool clear_settings){
301301
// return "No connection set.";
302302
// }
303303

304+
// cout << "Checking readiness... " << (int)m_desired_controller << endl;
305+
if (m_connection && m_connection->is_ready()){
306+
m_desired_controller = m_connection->current_controller();
307+
// cout << "Ready! - " << (int)m_desired_controller << endl;
308+
}
309+
304310
// Move these out to indicate that we should no longer access them.
305311
controller = std::move(m_controller);
306312
connection = std::move(m_connection);
@@ -358,7 +364,11 @@ void ControllerSession::post_connection_ready(ControllerConnection& connection){
358364
}
359365

360366
reset_mode = m_next_reset_mode;
367+
368+
supported_controllers = m_connection->controller_list();
369+
current_controller = m_connection->current_controller();
361370
}
371+
signal_controller_changed(current_controller, supported_controllers);
362372

363373
// Construct the controller.
364374
if (desired_controller != ControllerType::None){
@@ -389,7 +399,6 @@ void ControllerSession::post_connection_ready(ControllerConnection& connection){
389399
// cout << "current_controller = " << CONTROLLER_TYPE_STRINGS.get_string(current_controller) << endl;
390400
ready = m_controller && m_controller->is_ready();
391401
}
392-
393402
signal_controller_changed(current_controller, supported_controllers);
394403
signal_ready_changed(ready);
395404
signal_status_text_changed(status_text());

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const std::map<pabb_ProgramID, uint32_t>& SUPPORTED_DEVICES(){
2323
{PABB_PID_PABOTBASE_TeensyPP2, 2025090300},
2424
{PABB_PID_PABOTBASE_ESP32, 2025090300},
2525
{PABB_PID_PABOTBASE_ESP32S3, 2025090300},
26-
{PABB_PID_PABOTBASE_PicoW_USB, 2025090300},
27-
{PABB_PID_PABOTBASE_PicoW_UART, 2025090300},
2826
};
2927
return database;
3028
}

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,17 @@ ControllerType SerialPABotBase_Connection::process_device(bool set_to_null_contr
179179
if (PROGRAMS.find(m_program_id) == PROGRAMS.end()){
180180
#if 1
181181
m_logger.Logger::log(
182-
"Unrecognized Program ID: 0x" + tostr_hex(m_program_id) + " for this protocol version. "
182+
"Unrecognized Program ID: (0x" + tostr_hex(m_program_id) + ") for this protocol version. "
183183
"Compatibility is not guaranteed.",
184184
COLOR_RED
185185
);
186+
if (PROGRAMS.find(PABB_PID_UNSPECIFIED) == PROGRAMS.end()){
187+
throw SerialProtocolException(
188+
m_logger, PA_CURRENT_FUNCTION,
189+
"Unrecognized program IDs require latest protocol.<br>"
190+
"Program ID: 0x" + tostr_hex(m_program_id) + ", Device Protocol: " + std::to_string(m_protocol)
191+
);
192+
}
186193
#else
187194
throw SerialProtocolException(
188195
m_logger, PA_CURRENT_FUNCTION,
@@ -288,7 +295,7 @@ void SerialPABotBase_Connection::thread_body(bool set_to_null_controller){
288295
error = e.message();
289296
}
290297
if (!error.empty()){
291-
m_ready.store(false, std::memory_order_relaxed);
298+
// m_ready.store(false, std::memory_order_relaxed);
292299
set_status_line0(error, COLOR_RED);
293300
// signal_pre_not_ready();
294301
m_botbase->stop();

0 commit comments

Comments
 (0)