From da2f60ae951d34609122c415d1f974f210ef35b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Jan 2020 09:08:17 +1100 Subject: [PATCH] AP_SerialManager: ensure users can't break SERIAL0_PROTOCOL this prevents users from setting SERIAL0_PROTOCOL to something that prevents them accessing the board. This can happen when users are trying to setup SLCAN --- libraries/AP_SerialManager/AP_SerialManager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/AP_SerialManager/AP_SerialManager.cpp b/libraries/AP_SerialManager/AP_SerialManager.cpp index f0d208605f..d24ef69f5e 100644 --- a/libraries/AP_SerialManager/AP_SerialManager.cpp +++ b/libraries/AP_SerialManager/AP_SerialManager.cpp @@ -355,6 +355,18 @@ void AP_SerialManager::init() state[7].uart = hal.uartH; // serial7 #endif +#ifdef HAL_OTG1_CONFIG + /* + prevent users from changing USB protocol to other than + MAVLink. This fixes an issue where users trying to get SLCAN + change SERIAL0_PROTOCOL to 22 and find they can no longer connect + */ + if (state[0].protocol != SerialProtocol_MAVLink && + state[0].protocol != SerialProtocol_MAVLink2) { + state[0].protocol.set(SerialProtocol_MAVLink2); + } +#endif + #if SERIALMANAGER_NUM_PORTS > 0 if (state[0].uart == nullptr) { init_console();