Browse Source

AP_BoardConfig_CAN: put debug code behind compile-time flag

And disable it by default
master
Francisco Ferreira 7 years ago
parent
commit
b7a3e1ae77
No known key found for this signature in database
GPG Key ID: F63C20A6773E787E
  1. 12
      libraries/AP_BoardConfig/AP_BoardConfig_CAN.h
  2. 2
      libraries/AP_BoardConfig/canbus_interface.cpp

12
libraries/AP_BoardConfig/AP_BoardConfig_CAN.h

@ -6,6 +6,10 @@ @@ -6,6 +6,10 @@
#include <AP_Param/AP_Param.h>
#ifndef AP_CAN_DEBUG
#define AP_CAN_DEBUG 0
#endif
class AP_BoardConfig_CAN {
public:
AP_BoardConfig_CAN();
@ -30,31 +34,37 @@ public: @@ -30,31 +34,37 @@ public:
// return debug level for interface i
uint8_t get_debug_level(uint8_t i) {
#if AP_CAN_DEBUG
if (i < MAX_NUMBER_OF_CAN_INTERFACES) {
return _interfaces[i]._driver_number_cache ? _interfaces[i]._debug_level : 0;
}
#endif
return 0;
}
// return maximum level of debug of all interfaces
uint8_t get_debug_level(void) {
uint8_t ret = 0;
#if AP_CAN_DEBUG
for (uint8_t i = 0; i < MAX_NUMBER_OF_CAN_INTERFACES; i++) {
uint8_t dbg = get_debug_level(i);
ret = (dbg > ret) ? dbg : ret;
}
#endif
return ret;
}
// return maximum level of debug for driver index i
uint8_t get_debug_level_driver(uint8_t i) {
uint8_t ret = 0;
#if AP_CAN_DEBUG
for (uint8_t j = 0; j < MAX_NUMBER_OF_CAN_INTERFACES; j++) {
if (_interfaces[j]._driver_number_cache == i) {
uint8_t dbg = get_debug_level(j);
ret = (dbg > ret) ? dbg : ret;
}
}
#endif
return ret;
}
@ -91,7 +101,9 @@ private: @@ -91,7 +101,9 @@ private:
AP_Int8 _driver_number;
uint8_t _driver_number_cache;
AP_Int32 _bitrate;
#if AP_CAN_DEBUG
AP_Int8 _debug_level;
#endif
};
class Driver {

2
libraries/AP_BoardConfig/canbus_interface.cpp

@ -35,12 +35,14 @@ const AP_Param::GroupInfo AP_BoardConfig_CAN::Interface::var_info[] = { @@ -35,12 +35,14 @@ const AP_Param::GroupInfo AP_BoardConfig_CAN::Interface::var_info[] = {
// @User: Advanced
AP_GROUPINFO("BITRATE", 2, AP_BoardConfig_CAN::Interface, _bitrate, 1000000),
#if AP_CAN_DEBUG
// @Param: DEBUG
// @DisplayName: Level of debug for CAN devices
// @Description: Enabling this option will provide debug messages
// @Values: 0:Disabled,1:Major messages,2:All messages
// @User: Advanced
AP_GROUPINFO("DEBUG", 3, AP_BoardConfig_CAN::Interface, _debug_level, 1),
#endif
AP_GROUPEND
};

Loading…
Cancel
Save