diff --git a/libraries/AP_HAL_Linux/CAN.cpp b/libraries/AP_HAL_Linux/CAN.cpp index 632dbea3bd..712339abfb 100644 --- a/libraries/AP_HAL_Linux/CAN.cpp +++ b/libraries/AP_HAL_Linux/CAN.cpp @@ -83,7 +83,10 @@ static uavcan::CanFrame makeUavcanFrame(const can_frame& sockcan_frame) bool CAN::begin(uint32_t bitrate) { - if (_initialized) return _initialized; + if (_initialized) { + return _initialized; + } + // TODO: Add possibility change bitrate _fd = openSocket(HAL_BOARD_CAN_IFACE_NAME); if (_fd > 0) { @@ -537,15 +540,16 @@ int16_t CANManager::select(uavcan::CanSelectMasks& inout_masks, IfaceWrapper* pollfd_index_to_iface[uavcan::MaxCanIfaces] = {}; for (unsigned i = 0; i < _ifaces.size(); i++) { - if (!_ifaces[i]->isDown()) { - pollfds[num_pollfds].fd = _ifaces[i]->getFileDescriptor(); - pollfds[num_pollfds].events = POLLIN; - if (_ifaces[i]->hasReadyTx() || (inout_masks.write & (1U << i))) { - pollfds[num_pollfds].events |= POLLOUT; - } - pollfd_index_to_iface[num_pollfds] = _ifaces[i].get(); - num_pollfds++; + if (_ifaces[i]->isDown()) { + continue; } + pollfds[num_pollfds].fd = _ifaces[i]->getFileDescriptor(); + pollfds[num_pollfds].events = POLLIN; + if (_ifaces[i]->hasReadyTx() || (inout_masks.write & (1U << i))) { + pollfds[num_pollfds].events |= POLLOUT; + } + pollfd_index_to_iface[num_pollfds] = _ifaces[i].get(); + num_pollfds++; } if (num_pollfds == 0) {