Class: CommandParser

CommandParser()

Command parser used for looking up commands in the xml definition

Constructor

new CommandParser()

CommandParser constructor

Source:

Methods

getCommand(projectName, className, commandName, commandArgumentsnullable) → {DroneCommand}

Get a command based on it's path in the xml definition

Parameters:
Name Type Attributes Description
projectName string

The xml file name (project name)

className string

The command class name

commandName string

The command name

commandArguments Object <nullable>

Optional command arguments

Source:
See:
Throws:

InvalidCommandError

Returns:
  • Target command
Type
DroneCommand
Example
const parser = new CommandParser();
const backFlip = parser.getCommand('minidrone', 'Animations', 'Flip', {direction: 'back'});

parseBuffer(buffer) → {DroneCommand}

Parse the input buffer and get the correct command with parameters Used internally to parse sensor data

Parameters:
Name Type Description
buffer Buffer

The command buffer without the first two bytes

Source:
Throws:
  • InvalidCommandError

  • TypeError

Returns:
  • Parsed drone command
Type
DroneCommand

warmup(files) → {void}

Warn up the parser by pre-fetching the xml files

Parameters:
Name Type Description
files Array.<string>

List of files to load in defaults to CommandParser._files

Source:
Returns:
Type
void