AP_HAL_SITL: convert to using hal.serial() instead of hal.uartX

This commit is contained in:
Andrew Tridgell 2020-12-11 11:18:38 +11:00
parent db76eebd85
commit cf187ff837
3 changed files with 7 additions and 13 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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<hal.num_serial; i++) {
hal.serial(i)->_timer_tick();
}
hal.storage->_timer_tick();
#ifndef HAL_BUILD_AP_PERIPH