Skip to content

Commit

Permalink
DataFlash: clear format sent mask when backend starts new log
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed May 1, 2017
1 parent 2876f14 commit ac1484f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions libraries/DataFlash/DataFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ void DataFlash_Class::Log_Write_MessageF(const char *fmt, ...)
Log_Write_Message(msg);
}

void DataFlash_Class::backend_starting_new_log(const DataFlash_Backend *backend)
{
for (uint8_t i=0; i<_next_backend; i++) {
if (backends[i] == backend) { // pointer comparison!
// reset sent masks
for (struct log_write_fmt *f = log_write_fmts; f; f=f->next) {
f->sent_mask &= ~(1<<i);
}
break;
}
}
}

#define FOR_EACH_BACKEND(methodcall) \
do { \
for (uint8_t i=0; i<_next_backend; i++) { \
Expand Down
4 changes: 3 additions & 1 deletion libraries/DataFlash/DataFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class DataFlash_Class
void Log_Write_EKF2(AP_AHRS_NavEKF &ahrs, bool optFlowEnabled);
void Log_Write_EKF3(AP_AHRS_NavEKF &ahrs, bool optFlowEnabled);
#endif


void backend_starting_new_log(const DataFlash_Backend *backend);

private:
static DataFlash_Class *_instance;

Expand Down
1 change: 1 addition & 0 deletions libraries/DataFlash/DataFlash_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void DataFlash_Backend::periodic_tasks()
void DataFlash_Backend::start_new_log_reset_variables()
{
_startup_messagewriter->reset();
_front.backend_starting_new_log(this);
}

void DataFlash_Backend::internal_error() {
Expand Down
7 changes: 3 additions & 4 deletions libraries/DataFlash/LogFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,14 @@ void DataFlash_Block::ListAvailableLogs(AP_HAL::BetterStream *port)

// This function starts a new log file in the DataFlash, and writes
// the format of supported messages in the log
// This function is ONLY called from the vehicle code.
// DataFlash_MAVLink, for example, will NOT call this function if the
// remote end disconnects and reconnects!
void DataFlash_Class::StartNewLog(void)
{
for (uint8_t i=0; i<_next_backend; i++) {
backends[i]->start_new_log();
}
// reset sent masks
for (struct log_write_fmt *f = log_write_fmts; f; f=f->next) {
f->sent_mask = 0;
}
}

/*
Expand Down

0 comments on commit ac1484f

Please sign in to comment.