-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cliDebugPrint functions to facilitate easy debug printing to CLI (#…
…448) port of betaflight/betaflight#8905 thanks to @etracer65 for original commit in betalfight To use, include cli/cli_debug_print.h in your code and be sure USE_CLI_DEBUG_PRINT is defined. Or alternately, build using make TARGET=<target_name> OPTIONS="USE_CLI_DEBUG_PRINT". Then you'll have access to the following functions to print debugging messages in the CLI: cliDebugPrintLineFeed cliDebugPrint cliDebugPrintLine cliDebugPrintf cliDebugPrintLinef Output is suppressed when the CLI is not open. The functions are equivalent to their cliPrint... counterparts. May interfere with the autocomplete initialization when first entering the CLI if your code is outputting data when the CLI first opens. But as this is only meant for debugging it shouldn't be much of a concern. You may also need to rate limit your messages if printing data in a loop. Using these calls in other modules should only used for debugging and not left in any finished code. Co-authored-by: Igor Shpakov <[email protected]> Co-authored-by: etracer65 <[email protected]>
- Loading branch information
1 parent
11e4402
commit c6022f8
Showing
3 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of Cleanflight and Betaflight. | ||
* | ||
* Cleanflight and Betaflight are free software. You can redistribute | ||
* this software and/or modify this software under the terms of the | ||
* GNU General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* Cleanflight and Betaflight are distributed in the hope that they | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this software. | ||
* | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// Provides: cliPrintDebug... functions for displaying debugging information in the CLI | ||
// | ||
// Usage: Make sure USE_CLI_DEBUG_PRINT is defined | ||
// Include this header in your code | ||
// Add cliDebugPrint... statements as needed in your code | ||
// Use the CLI to see the output of the debugging statements | ||
// | ||
// Cautions: Be sure to include rate limiting logic to your debug printing | ||
// if needed otherwise you can flood the output. | ||
// | ||
// Be sure to reverse the Usage steps above to remove the debugging | ||
// elements before submitting final code. | ||
|
||
#include "platform.h" | ||
|
||
#ifdef USE_CLI_DEBUG_PRINT | ||
|
||
#include "interface/cli.h" | ||
|
||
// Commands to print debugging information to the CLI | ||
#define cliDebugPrintLinefeed cliPrintLinefeed | ||
#define cliDebugPrintLinef cliPrintLinef | ||
#define cliDebugPrintLine cliPrintLine | ||
#define cliDebugPrintf cliPrintf | ||
#define cliDebugPrint cliPrint | ||
|
||
#else | ||
#error "Do not #include cli_debug_print.h unless you intend to do debugging and also define USE_CLI_DEBUG_PRINT" | ||
#endif |