From cf187ff837908e01aa2b3ac991f1a4a861bb4160 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Dec 2020 11:18:38 +1100 Subject: [PATCH] AP_HAL_SITL: convert to using hal.serial() instead of hal.uartX --- libraries/AP_HAL_SITL/HAL_SITL_Class.cpp | 4 ++-- libraries/AP_HAL_SITL/SITL_State.cpp | 2 +- libraries/AP_HAL_SITL/Scheduler.cpp | 14 ++++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libraries/AP_HAL_SITL/HAL_SITL_Class.cpp b/libraries/AP_HAL_SITL/HAL_SITL_Class.cpp index 3b8d504723..b791c7434b 100644 --- a/libraries/AP_HAL_SITL/HAL_SITL_Class.cpp +++ b/libraries/AP_HAL_SITL/HAL_SITL_Class.cpp @@ -182,7 +182,7 @@ void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const _sitl_state->init(argc, argv); scheduler->init(); - uartA->begin(115200); + serial(0)->begin(115200); rcin->init(); rcout->init(); @@ -193,7 +193,7 @@ void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const if (getenv("SITL_WATCHDOG_RESET")) { INTERNAL_ERROR(AP_InternalError::error_t::watchdog_reset); if (watchdog_load((uint32_t *)&utilInstance.persistent_data, (sizeof(utilInstance.persistent_data)+3)/4)) { - uartA->printf("Loaded watchdog data"); + serial(0)->printf("Loaded watchdog data"); utilInstance.last_persistent_data = utilInstance.persistent_data; } } diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index 65255de58e..8ebd905d48 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -216,7 +216,7 @@ void SITL_State::wait_clock(uint64_t wait_time_usec) // conditions. if (sitl_model->get_speedup() > 1) { while (true) { - const int queue_length = ((HALSITL::UARTDriver*)hal.uartA)->get_system_outqueue_length(); + const int queue_length = ((HALSITL::UARTDriver*)hal.serial(0))->get_system_outqueue_length(); // ::fprintf(stderr, "queue_length=%d\n", (signed)queue_length); if (queue_length < 1024) { break; diff --git a/libraries/AP_HAL_SITL/Scheduler.cpp b/libraries/AP_HAL_SITL/Scheduler.cpp index 0c05d86230..4c9a11e7d7 100644 --- a/libraries/AP_HAL_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_SITL/Scheduler.cpp @@ -167,7 +167,7 @@ void Scheduler::system_initialized() { void Scheduler::sitl_end_atomic() { if (_nested_atomic_ctr == 0) { - hal.uartA->printf("NESTED ATOMIC ERROR\n"); + hal.serial(0)->printf("NESTED ATOMIC ERROR\n"); } else { _nested_atomic_ctr--; } @@ -235,15 +235,9 @@ void Scheduler::_run_io_procs() _in_io_proc = false; - hal.uartA->_timer_tick(); - hal.uartB->_timer_tick(); - hal.uartC->_timer_tick(); - hal.uartD->_timer_tick(); - hal.uartE->_timer_tick(); - hal.uartF->_timer_tick(); - hal.uartG->_timer_tick(); - hal.uartH->_timer_tick(); - hal.uartI->_timer_tick(); + for (uint8_t i=0; i_timer_tick(); + } hal.storage->_timer_tick(); #ifndef HAL_BUILD_AP_PERIPH