Browse Source

SRV_Channels: helper func

mission-4.1.18
Eugene Shamaev 7 years ago committed by Andrew Tridgell
parent
commit
66438041ad
  1. 20
      libraries/SRV_Channel/SRV_Channels.cpp

20
libraries/SRV_Channel/SRV_Channels.cpp

@ -249,33 +249,29 @@ void SRV_Channels::push_UAVCAN(void)
} }
for (uint8_t i = 0; i < MAX_NUMBER_OF_CAN_DRIVERS; i++) { for (uint8_t i = 0; i < MAX_NUMBER_OF_CAN_DRIVERS; i++) {
if (hal.can_mgr[i] == nullptr) { AP_UAVCAN *ap_uavcan = AP_UAVCAN::get_uavcan(i);
continue; if (ap_uavcan == nullptr) {
} return;
AP_UAVCAN *uavcan = hal.can_mgr[i]->get_UAVCAN();
if (uavcan == nullptr) {
continue;
} }
if (!uavcan->SRV_sem_take()) { if (!ap_uavcan->SRV_sem_take()) {
continue; continue;
} }
for (uint8_t j = 0; j < NUM_SERVO_CHANNELS; j++) { for (uint8_t j = 0; j < NUM_SERVO_CHANNELS; j++) {
// Check if this channels has any function assigned // Check if this channels has any function assigned
if (channel_function(j)) { if (channel_function(j)) {
uavcan->SRV_write(channels[j].get_output_pwm(), j); ap_uavcan->SRV_write(channels[j].get_output_pwm(), j);
} }
} }
if (hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED) { if (hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED) {
uavcan->SRV_arm_actuators(true); ap_uavcan->SRV_arm_actuators(true);
} else { } else {
uavcan->SRV_arm_actuators(false); ap_uavcan->SRV_arm_actuators(false);
} }
uavcan->SRV_sem_give(); ap_uavcan->SRV_sem_give();
} }
#endif // HAL_WITH_UAVCAN #endif // HAL_WITH_UAVCAN
} }

Loading…
Cancel
Save