Firmware
Macros | Functions
px4_module.h File Reference
#include <pthread.h>
#include <unistd.h>
#include <stdbool.h>
#include <px4_atomic.h>
#include <px4_time.h>
#include <px4_log.h>
#include <px4_tasks.h>
#include <systemlib/px4_macros.h>

Go to the source code of this file.

Macros

#define PRINT_MODULE_USAGE_COMMAND(name)   PRINT_MODULE_USAGE_COMMAND_DESCR(name, NULL);
 
#define PRINT_MODULE_USAGE_DEFAULT_COMMANDS()
 Prints the default commands: stop & status. More...
 

Functions

__BEGIN_DECLS __EXPORT void PRINT_MODULE_DESCRIPTION (const char *description)
 Module documentation and command usage help methods. More...
 
__EXPORT void PRINT_MODULE_USAGE_NAME (const char *executable_name, const char *category)
 Prints the command name. More...
 
__EXPORT void PRINT_MODULE_USAGE_SUBCATEGORY (const char *subcategory)
 Specify a subcategory (optional). More...
 
__EXPORT void PRINT_MODULE_USAGE_NAME_SIMPLE (const char *executable_name, const char *category)
 Prints the name for a command without any sub-commands (. More...
 
__EXPORT void PRINT_MODULE_USAGE_COMMAND_DESCR (const char *name, const char *description)
 Prints a command with a short description what it does.
 
__EXPORT void PRINT_MODULE_USAGE_PARAM_INT (char option_char, int default_val, int min_val, int max_val, const char *description, bool is_optional)
 Prints an integer parameter. More...
 
__EXPORT void PRINT_MODULE_USAGE_PARAM_FLOAT (char option_char, float default_val, float min_val, float max_val, const char *description, bool is_optional)
 Prints a float parameter. More...
 
__EXPORT void PRINT_MODULE_USAGE_PARAM_FLAG (char option_char, const char *description, bool is_optional)
 Prints a flag parameter, without any value. More...
 
__EXPORT void PRINT_MODULE_USAGE_PARAM_STRING (char option_char, const char *default_val, const char *values, const char *description, bool is_optional)
 Prints a string parameter. More...
 
__EXPORT void PRINT_MODULE_USAGE_PARAM_COMMENT (const char *comment)
 Prints a comment, that applies to the next arguments or parameters. More...
 
__EXPORT void PRINT_MODULE_USAGE_ARG (const char *values, const char *description, bool is_optional)
 Prints the definition for an argument, which does not have the typical -p <val> form, but for example 'param set '. More...
 

Macro Definition Documentation

§ PRINT_MODULE_USAGE_DEFAULT_COMMANDS

#define PRINT_MODULE_USAGE_DEFAULT_COMMANDS ( )
Value:
PRINT_MODULE_USAGE_COMMAND("stop"); \
PRINT_MODULE_USAGE_COMMAND_DESCR("status", "print status info");

Prints the default commands: stop & status.

Function Documentation

§ PRINT_MODULE_DESCRIPTION()

__BEGIN_DECLS __EXPORT void PRINT_MODULE_DESCRIPTION ( const char *  description)

Module documentation and command usage help methods.

These are extracted with the Tools/px_process_module_doc.py script and must be kept in sync. Prints module documentation (will also be used for online documentation). It uses Markdown syntax and should include these sections:

  • ### Description Provided functionality of the module and potentially the most important parameters.
  • ### Implementation High-level implementation overview
  • ### Examples Examples how to use the CLI interface (if it's non-trivial)

In addition to the Markdown syntax, a line beginning with '$ ' can be used to mark a command: $ module start -p param

§ PRINT_MODULE_USAGE_ARG()

__EXPORT void PRINT_MODULE_USAGE_ARG ( const char *  values,
const char *  description,
bool  is_optional 
)

Prints the definition for an argument, which does not have the typical -p <val> form, but for example 'param set '.

Parameters
valueseg. "<file>", "<param> <value>" or "<value1> [<value2>]"
descriptionPointer to the usage description.
is_optionaltrue if this parameter is optional

§ PRINT_MODULE_USAGE_NAME()

__EXPORT void PRINT_MODULE_USAGE_NAME ( const char *  executable_name,
const char *  category 
)

Prints the command name.

Parameters
executable_namecommand name used in scripts & CLI
categoryone of: driver, estimator, controller, system, communication, command, template

§ PRINT_MODULE_USAGE_NAME_SIMPLE()

__EXPORT void PRINT_MODULE_USAGE_NAME_SIMPLE ( const char *  executable_name,
const char *  category 
)

Prints the name for a command without any sub-commands (.

See also
PRINT_MODULE_USAGE_NAME()).

§ PRINT_MODULE_USAGE_PARAM_COMMENT()

__EXPORT void PRINT_MODULE_USAGE_PARAM_COMMENT ( const char *  comment)

Prints a comment, that applies to the next arguments or parameters.

For example to indicate that a parameter applies to several or all commands.

Parameters
comment

§ PRINT_MODULE_USAGE_PARAM_FLAG()

__EXPORT void PRINT_MODULE_USAGE_PARAM_FLAG ( char  option_char,
const char *  description,
bool  is_optional 
)

Prints a flag parameter, without any value.

Note
See PRINT_MODULE_USAGE_PARAM_INT().
Parameters
option_charThe option character.
descriptionPointer to the usage description.
is_optionaltrue if this parameter is optional

§ PRINT_MODULE_USAGE_PARAM_FLOAT()

__EXPORT void PRINT_MODULE_USAGE_PARAM_FLOAT ( char  option_char,
float  default_val,
float  min_val,
float  max_val,
const char *  description,
bool  is_optional 
)

Prints a float parameter.

Note
See PRINT_MODULE_USAGE_PARAM_INT().
Parameters
default_valThe parameter default value (set to NaN if not applicable).
min_valThe parameter minimum value.
max_valThe parameter maximum value.
descriptionPointer to the usage description. Pointer to the usage description.
is_optionaltrue if this parameter is optional

§ PRINT_MODULE_USAGE_PARAM_INT()

__EXPORT void PRINT_MODULE_USAGE_PARAM_INT ( char  option_char,
int  default_val,
int  min_val,
int  max_val,
const char *  description,
bool  is_optional 
)

Prints an integer parameter.

Note
Each of the PRINT_MODULE_USAGE_PARAM_* methods apply to the previous PRINT_MODULE_USAGE_COMMAND_DESCR().
Parameters
option_charThe option character.
default_valThe parameter default value (set to -1 if not applicable).
min_valThe parameter minimum value.
max_valThe parameter value.
descriptionPointer to the usage description.
is_optionaltrue if this parameter is optional

§ PRINT_MODULE_USAGE_PARAM_STRING()

__EXPORT void PRINT_MODULE_USAGE_PARAM_STRING ( char  option_char,
const char *  default_val,
const char *  values,
const char *  description,
bool  is_optional 
)

Prints a string parameter.

Parameters
option_charThe option character.
default_valThe default value, can be nullptr.
valuesThe valid values, it has one of the following forms:
  • nullptr: leave unspecified, or any value is valid
  • "<file>" or "<file:dev>": a file or more specifically a device file (eg. serial device)
  • "<topic_name>": uORB topic name
  • "<value1> [<value2>]": a list of values
  • "on|off": a concrete set of valid strings separated by "|".
descriptionPointer to the usage description.
is_optionalTrue iff this parameter is optional.

§ PRINT_MODULE_USAGE_SUBCATEGORY()

__EXPORT void PRINT_MODULE_USAGE_SUBCATEGORY ( const char *  subcategory)

Specify a subcategory (optional).

Parameters
subcategorye.g. if the category is 'driver', subcategory can be 'distance_sensor'