bool AP_InertialSensor::BatchSampler::should_log(uint8_t _instance, IMU_SENSOR_TYPE _type) { if (_sensor_mask == 0) { return false; } if (!initialised) { return false; } if (_instance != instance) { return false; } if (_type != type) { return false; } if (data_write_offset >= _required_count) { return false; } AP_Logger *logger = AP_Logger::get_singleton(); if (logger == nullptr) { return false; } #define MASK_LOG_ANY 0xFFFF if (!logger->should_log(MASK_LOG_ANY)) { return false; } return true; }
// read - read the voltage and current for all instances void AP_BattMonitor::read() { for (uint8_t i=0; i<_num_instances; i++) { if (drivers[i] != nullptr && _params[i].type() != AP_BattMonitor_Params::BattMonitor_TYPE_NONE) { drivers[i]->read(); drivers[i]->update_resistance_estimate(); } } AP_Logger *df = AP_Logger::get_singleton(); if (df->should_log(_log_battery_bit)) { df->Write_Current(); df->Write_Power(); } check_failsafes(); checkPoweringOff(); }
void OpticalFlow::Log_Write_Optflow() { AP_Logger *instance = AP_Logger::instance(); if (instance == nullptr) { return; } if (_log_bit != (uint32_t)-1 && !instance->should_log(_log_bit)) { return; } struct log_Optflow pkt = { LOG_PACKET_HEADER_INIT(LOG_OPTFLOW_MSG), time_us : AP_HAL::micros64(), surface_quality : _state.surface_quality, flow_x : _state.flowRate.x, flow_y : _state.flowRate.y, body_x : _state.bodyRate.x, body_y : _state.bodyRate.y }; instance->WriteBlock(&pkt, sizeof(pkt)); }