AP_CANManager: use ExpandingString class

This commit is contained in:
Andrew Tridgell 2020-12-30 17:23:26 +11:00 committed by Peter Barker
parent 6c1891fcb3
commit 0c6b4a1045
4 changed files with 9 additions and 10 deletions

View File

@ -39,6 +39,8 @@
#include <AP_HAL_ChibiOS/CANIface.h>
#endif
#include <AP_Common/ExpandingString.h>
#define LOG_TAG "CANMGR"
#define LOG_BUFFER_SIZE 1024
@ -373,15 +375,13 @@ void AP_CANManager::log_text(AP_CANManager::LogLevel loglevel, const char *tag,
}
// log retrieve method used by file sys method to report can log
uint32_t AP_CANManager::log_retrieve(char* data, uint32_t max_size) const
void AP_CANManager::log_retrieve(ExpandingString &str) const
{
if (_log_buf == nullptr) {
gcs().send_text(MAV_SEVERITY_ERROR, "Log buffer not available");
return 0;
return;
}
uint32_t read_len = MIN(max_size, _log_pos);
memcpy(data, _log_buf, read_len);
return read_len;
str.append(_log_buf, _log_pos);
}
AP_CANManager& AP::can()

View File

@ -90,7 +90,7 @@ public:
// Method to log status and debug information for review while debugging
void log_text(AP_CANManager::LogLevel loglevel, const char *tag, const char *fmt, ...);
uint32_t log_retrieve(char* data, uint32_t max_size) const;
void log_retrieve(ExpandingString &str) const;
// return driver type index i
Driver_Type get_driver_type(uint8_t i) const

View File

@ -536,13 +536,12 @@ uint32_t SLCAN::CANIface::getErrorCount() const
return 0;
}
uint32_t SLCAN::CANIface::get_stats(char* data, uint32_t max_size)
void SLCAN::CANIface::get_stats(ExpandingString &str)
{
// When in passthrough mode methods is handled through can iface
if (_can_iface) {
return _can_iface->get_stats(data, max_size);
_can_iface->get_stats(str);
}
return 0;
}
bool SLCAN::CANIface::is_busoff() const

View File

@ -112,7 +112,7 @@ public:
bool set_event_handle(AP_HAL::EventHandle* evt_handle) override;
uint16_t getNumFilters() const override;
uint32_t getErrorCount() const override;
uint32_t get_stats(char* data, uint32_t max_size) override;
void get_stats(ExpandingString &) override;
bool is_busoff() const override;
bool configureFilters(const CanFilterConfig* filter_configs, uint16_t num_configs) override;
void flush_tx() override;