DataFlash: support for mavlink SENSOR message

This commit is contained in:
Peter Barker 2016-07-07 17:12:27 +10:00 committed by Lucas De Marchi
parent a511f97971
commit 8d253dec8e
7 changed files with 68 additions and 1 deletions

View File

@ -40,6 +40,25 @@ const struct LogStructure *DataFlash_Class::structure(uint16_t num) const
return &_structures[num];
}
bool DataFlash_Class::logging_present() const
{
return _next_backend != 0;
}
bool DataFlash_Class::logging_enabled() const
{
if (_next_backend == 0) {
return false;
}
return backends[0]->logging_enabled();
}
bool DataFlash_Class::logging_failed() const
{
if (_next_backend < 1) {
// we should not have been called!
return true;
}
return backends[0]->logging_failed();
}
#define FOR_EACH_BACKEND(methodcall) \
do { \

View File

@ -200,6 +200,13 @@ public:
const struct LogStructure *structure(uint16_t num) const;
// methods for mavlink SYS_STATUS message (send_extended_status1)
// these methods cover only the first logging backend used -
// typically DataFlash_File.
bool logging_present() const;
bool logging_enabled() const;
bool logging_failed() const;
protected:
const struct LogStructure *_structures;

View File

@ -117,6 +117,10 @@ public:
// values contained in arg_list:
bool Log_Write(uint8_t msg_type, va_list arg_list, bool is_critical=false);
// these methods are used when reporting system status over mavlink
virtual bool logging_enabled() const = 0;
virtual bool logging_failed() const = 0;
protected:
uint32_t dropped;
uint8_t internal_errors; // uint8_t - wishful thinking?

View File

@ -1100,5 +1100,29 @@ void DataFlash_File::_io_timer(void)
hal.util->perf_end(_perf_write);
}
// this sensor is enabled if we should be logging at the moment
bool DataFlash_File::logging_enabled() const
{
if (hal.util->get_soft_armed() ||
_front.log_while_disarmed()) {
return true;
}
return false;
}
bool DataFlash_File::logging_failed() const
{
if (_write_fd == -1 &&
(hal.util->get_soft_armed() ||
_front.log_while_disarmed())) {
return true;
}
if (_open_error) {
return true;
}
return false;
}
#endif // HAL_OS_POSIX_IO

View File

@ -66,7 +66,11 @@ public:
void flush(void);
#endif
void periodic_fullrate(const uint32_t now);
// this method is used when reporting system status over mavlink
bool logging_enabled() const;
bool logging_failed() const;
private:
int _write_fd;
int _read_fd;

View File

@ -52,6 +52,11 @@ void DataFlash_MAVLink::Init()
// the vehicles
}
bool DataFlash_MAVLink::logging_failed() const
{
return !_sending_to_client;
}
uint16_t DataFlash_MAVLink::bufferspace_available() {
return (_blockcount_free * 200 + remaining_space_in_current_block());
}

View File

@ -127,6 +127,10 @@ protected:
uint8_t state_sent_max;
} stats;
// this method is used when reporting system status over mavlink
bool logging_enabled() const { return true; }
bool logging_failed() const;
private:
mavlink_channel_t _chan;
uint8_t _target_system_id;