blfwk::Command Class Reference

Represents a bootloader command. More...

`#include <Command.h>`

Inheritance diagram for blfwk::Command:
[legend]
Collaboration diagram for blfwk::Command:
[legend]

## Public Member Functions

virtual | ~Command ()
| Destructor.
virtual bool | init ()
| Initialize. More...
virtual void | sendTo (Packetizer &packetizer)
| Send command to packetizer and on to peripheral.
virtual const uint32_vector_t * | getResponseValues () const
| Get response values vector.
virtual std::string | getResponse () const
| Get response as JSON string.
void | logResponses () const
| Log the response description.
void | registerProgress (Progress *progress)
| initial the process callback.
String arguments accessors.
virtual std::string | getArg (int arg) const
| Get the specified argument.
virtual std::string | getName () const
| Get the command name (i.e. argv[0]).
virtual size_t | getArgCount () const
| Get the number of arguments, including the command name.

## Static Public Member Functions

static Command * | create (const string_vector_t *argv)
| Create an appropriate command subclass. More...
static std::string | getStatusMessage (status_t code)
| Get a status code description.

## Public Attributes

Progress * | m_progress
| Variable for progress control.

## Protected Member Functions

| Command (const string_vector_t *argv)
| Constructor that takes a command name and list of arguments. More...
| Command (const char *const name)
| Constructor that takes a command name. More...
virtual bool | processResponse (const generic_response_packet_t *packet, uint8_t commandTag)
| Check generic response packet. More...

## Protected Attributes

string_vector_t | m_argv
| Vector of argument strings.
uint32_vector_t | m_responseValues
| Vector of response values.
string | m_responseDetails
| Descriptive response.

## Detailed Description

Represents a bootloader command.

Do not instantiate this class. Instead, use the create() method to create the appropriate subclass based on command name in argv[0].

## Constructor & Destructor Documentation

blfwk::Command::Command | ( | const string_vector_t * | argv | ) |

inlineprotected

Constructor that takes a command name and list of arguments.

Parameters

  argv | Argument vector

blfwk::Command::Command | ( | const char *const | name | ) |

inlineprotected

Constructor that takes a command name.

Parameters

  name | Name of the command

## Member Function Documentation

Command * Command::create | ( | const string_vector_t * | argv | ) |

static

Create an appropriate command subclass.

Pass the command name in argv[0] and optional arguments in the rest of the string vector. Caller is responsible for deleting the returned object.

This factory method is just a shorthand for creating a subclass directly, for example:

string_vector_t cmdv;
cmdv.push_back("my-reset");
Reset * reset = new Reset(&cmdv);
reset->init();
Command * cmd = reset;

Parameters

  argv | Argument vector

Return values

  Command | object

virtual bool blfwk::Command::init | ( | void |  | ) |

inlinevirtual

Initialize.

Subclasses should implement init() to check for valid arguments.

Reimplemented in blfwk::ConfigureCan, blfwk::ConfigureSpi, blfwk::ConfigureI2c, blfwk::FlashImage, blfwk::ReliableUpdate, blfwk::ConfigureQuadSpi, blfwk::FlashReadResource, blfwk::FlashReadOnce, blfwk::FlashProgramOnce, blfwk::FlashSecurityDisable, blfwk::Call, blfwk::Execute, blfwk::ReceiveSbFile, blfwk::FillMemory, blfwk::WriteMemory, blfwk::ReadMemory, blfwk::FlashEraseAllUnsecure, blfwk::FlashEraseAll, blfwk::FlashEraseRegion, blfwk::SetProperty, blfwk::GetProperty, and blfwk::Reset.

bool Command::processResponse | ( | const generic_response_packet_t * | packet,
|  | uint8_t | commandTag
| ) |  |

protectedvirtual

Check generic response packet.

Parameters

  packet | Packet received from device
  commandTag | Expected command tag in packet

The documentation for this class was generated from the following files:

- Command.h
- Command.cpp