本文整理汇总了C++中DataFlash_Class::Log_Write_ISBH方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFlash_Class::Log_Write_ISBH方法的具体用法?C++ DataFlash_Class::Log_Write_ISBH怎么用?C++ DataFlash_Class::Log_Write_ISBH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFlash_Class
的用法示例。
在下文中一共展示了DataFlash_Class::Log_Write_ISBH方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void AP_InertialSensor::BatchSampler::push_data_to_log()
{
if (!initialised) {
return;
}
if (_sensor_mask == 0) {
return;
}
if (data_write_offset - data_read_offset < samples_per_msg) {
// insuffucient data to pack a packet
return;
}
const uint32_t now = AP_HAL::millis();
if (now - last_sent_ms < push_interval_ms) {
// avoid flooding DataFlash's buffer
return;
}
DataFlash_Class *dataflash = DataFlash_Class::instance();
if (dataflash == nullptr) {
// should not have been called
return;
}
// possibly send isb header:
if (!isbh_sent && data_read_offset == 0) {
float sample_rate = 0; // avoid warning about uninitialised values
switch(type) {
case IMU_SENSOR_TYPE_GYRO:
sample_rate = _imu._gyro_raw_sample_rates[instance];
break;
case IMU_SENSOR_TYPE_ACCEL:
sample_rate = _imu._accel_raw_sample_rates[instance];
break;
}
if (!dataflash->Log_Write_ISBH(isb_seqnum,
type,
instance,
multiplier,
_required_count,
measurement_started_us,
sample_rate)) {
// buffer full?
return;
}
isbh_sent = true;
}
// pack and send a data packet:
if (!dataflash->Log_Write_ISBD(isb_seqnum,
data_read_offset/samples_per_msg,
&data_x[data_read_offset],
&data_y[data_read_offset],
&data_z[data_read_offset])) {
// maybe later?!
return;
}
data_read_offset += samples_per_msg;
last_sent_ms = AP_HAL::millis();
if (data_read_offset >= _required_count) {
// that was the last one. Clean up:
data_read_offset = 0;
isb_seqnum++;
isbh_sent = false;
// rotate to next instance:
rotate_to_next_sensor();
data_write_offset = 0; // unlocks writing process
}
}