Modules#
Command Interpreter#
Interpret serial port commands. See command-interpreter2.c for source code.
See the following application usage example followed by a brief explanation.
⁄⁄ Usage: network form 22 0xAB12 -3 { 00 01 02 A3 A4 A5 A6 A7 }
void formCommand(void)
{
uint8_t channel = emberUnsignedCommandArgument(0);
uint16_t panId = emberUnsignedCommandArgument(1);
int8_t power = emberSignedCommandArgument(2);
uint8_t length;
uint8_t *eui64 = emberStringCommandArgument(3, &length);
...
... call emberFormNetwork() etc
...
}
⁄⁄ The main command table.
EmberCommandEntry emberCommandTable[] = {
emberCommandEntrySubMenu("network", networkCommands, "Network form/join commands"),
emberCommandEntryAction("status", statusCommand, "Prints application status),
...
emberCommandEntryTerminator()
};
⁄⁄ The table of network commands.
EmberCommandEntry networkCommands[] = {
emberCommandEntryAction("form", formCommand, "uvsh", "Form a network"),
emberCommandEntryAction("join", joinCommand, "uvsh", "Join a network"),
...
emberCommandEntryTerminator()
};
void main(void)
{
emberCommandReaderInit();
while(0) {
...
⁄⁄ Process input and print prompt if it returns true.
if (emberProcessCommandInput(serialPort)) {
emberSerialPrintf(1, "%p>", PROMPT);
}
...
}
}
Applications specify the commands that can be interpreted by defining the emberCommandTable array of type EmberCommandEntry. The table includes the following information for each command:
The full command name.
Your application's function name that implements the command.
An EmberCommandEntry::argumentTypes string specifies the number and types of arguments the command accepts. See ::argumentTypes for details.
A description string explains the command.
A default error handler emberCommandErrorHandler() is provided to deal with incorrect command input. Applications may override it.
The application calls emberCommandReaderInit() to initalize, and emberProcessCommandInput() in its main loop.
Within the application's command functions, use emberXXXCommandArgument() functions to retrieve command arguments.
The command interpreter does extensive processing and validation of the command input before calling the function that implements the command. It checks that the number, type, syntax, and range of all arguments are correct. It performs any conversions necessary (for example, converting integers and strings input in hexadecimal notation into the corresponding bytes), so that no additional parsing is necessary within command functions. If there is an error in the command input, emberCommandErrorHandler() is called rather than a command function.
The command interpreter allows inexact matches of command names. The input command may be either shorter or longer than the actual command. However, if more than one inexact match is found and there is no exact match, an error of type EMBER_CMD_ERR_NO_SUCH_COMMAND will be generated. To disable this feature, define EMBER_REQUIRE_EXACT_COMMAND_NAME in the application configuration header.
Functions to Retrieve Arguments#
Use the following functions in your functions that process commands to retrieve arguments from the command interpreter. These functions pull out unsigned integers, signed integers, and strings, and hex strings. Index 0 is the first command argument.
Enumerations#
Command error states.
Typedefs#
Variables#
Functions#
Initialize the command interpreter.
Process the given string as a command.
Returns true interpreter is reading a command.
Macros#
Process input coming in on the given serial port.
Turn echo of command line on.
Turn echo of command line off.
Returns true if echo is on, false otherwise.
Command Table Settings Documentation#
EMBER_MAX_COMMAND_ARGUMENTS#
#define EMBER_MAX_COMMAND_ARGUMENTSValue:
16
The maximum number of arguments a command can have. A nested command counts as an argument.
113
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
EMBER_COMMAND_BUFFER_LENGTH#
#define EMBER_COMMAND_BUFFER_LENGTHValue:
100
The maximum number of arguments a command can have. A nested command counts as an argument.
117
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD#
#define EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD
Whether or not the command entry structure will include descriptions for the commands. This consumes additional CONST space. By default descriptions are not included.
125
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Functions to Retrieve Arguments Documentation#
emberCommandArgumentCount#
uint8_t emberCommandArgumentCount (void )
N/A |
Returns the number of arguments for the current command.
302
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberUnsignedCommandArgument#
uint32_t emberUnsignedCommandArgument (uint8_t argNum)
N/A | argNum |
Retrieves unsigned integer arguments.
305
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberSignedCommandArgument#
int32_t emberSignedCommandArgument (uint8_t argNum)
N/A | argNum |
Retrieves signed integer arguments.
308
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberStringToHostOrderIpv4Address#
bool emberStringToHostOrderIpv4Address (const uint8_t * string, uint32_t * hostOrderIpv4Address)
N/A | string | |
N/A | hostOrderIpv4Address |
Parses an IPv4 address string and returns a host order uint32_t. Returns true if address is valid dotted quad notation (A.B.C.D), false otherwise.
313
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberStringArgumentToHostOrderIpv4Address#
bool emberStringArgumentToHostOrderIpv4Address (uint8_t argNum, uint32_t * hostOrderIpv4Address)
N/A | argNum | |
N/A | hostOrderIpv4Address |
Parses an IPv4 address string from a command argument and returns host order uint32_t. Returns true if address is valid dotted quad notation (A.B.C.D), false otherwise.
318
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberStringCommandArgument#
uint8_t* emberStringCommandArgument (int8_t argNum, uint8_t * length)
N/A | argNum | |
N/A | length |
Retrieve quoted string or hex string arguments. Hex strings have already been converted into binary. To retrieve the name of the command itself, use an argNum of -1. For example, to retrieve the first character of the command, do: uint8_t firstChar = emberStringCommandArgument(-1, NULL)[0]. If the command is nested, an index of -2, -3, etc will work to retrieve the higher level command names. Note that [-1] only returns the text entered. If an abbreviated command name is entered only the text entered will be returned with [-1].
330
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandName#
const char* emberCommandName (void )
N/A |
A convenience macro for copying security key arguments to an EmberKeyData pointer.
332
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCopyStringArgument#
uint8_t emberCopyStringArgument (int8_t argNum, uint8_t * destination, uint8_t maxLength, bool leftPad)
N/A | argNum | |
N/A | destination | |
N/A | maxLength | |
N/A | leftPad |
Copies the string argument to the given destination up to maxLength. If the argument length is nonzero but less than maxLength and leftPad is true, leading zeroes are prepended to bring the total length of the target up to maxLength. If the argument is longer than the maxLength, it is truncated to maxLength. Returns the minimum of the argument length and maxLength.
This function is commonly used for reading in hex strings such as EUI64 or key data and left padding them with zeroes. See emberCopyKeyArgument and emberCopyEui64Argument for convenience macros for this purpose.
346
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCopyBigEndianEui64Argument#
uint8_t emberCopyBigEndianEui64Argument (int8_t index, EmberEUI64 destination)
N/A | index | |
N/A | destination |
Copies eui64 arguments in big-endian format to an EmberEUI64. This is useful because eui64s are often presented to users in big-endian format even though they are used in software in little-endian format.
370
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCopyKeyArgument#
#define emberCopyKeyArgumentValue:
A convenience macro for copying security key arguments to an EmberKeyData pointer.
354
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCopyEui64Argument#
#define emberCopyEui64ArgumentValue:
(index, eui64)
A convenience macro for copying eui64 arguments to an EmberEUI64.
361
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberGetEui64Argument#
#define emberGetEui64ArgumentValue:
(index, eui64)
A convenience macro for copying security key arguments to an EmberKeyData pointer.
363
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Enumeration Documentation#
EmberCommandStatus#
EmberCommandStatus
Command error states.
If you change this list, ensure you also change the strings that describe these errors in the array emberCommandErrorNames[] in command-interpreter.c.
Enumerator | |
---|---|
EMBER_CMD_SUCCESS | |
EMBER_CMD_ERR_PORT_PROBLEM | |
EMBER_CMD_ERR_NO_SUCH_COMMAND | |
EMBER_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS | |
EMBER_CMD_ERR_ARGUMENT_OUT_OF_RANGE | |
EMBER_CMD_ERR_ARGUMENT_SYNTAX_ERROR | |
EMBER_CMD_ERR_STRING_TOO_LONG | |
EMBER_CMD_ERR_INVALID_ARGUMENT_TYPE |
277
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Typedef Documentation#
CommandAction#
typedef void(* CommandAction) (void) )(void)
134
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Variable Documentation#
emberCurrentCommand#
EmberCommandEntry* emberCurrentCommand
A pointer to the currently matching command entry. Only valid from within a command function. If the original command was nested, points to the final (non-nested) command entry.
260
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandTable#
EmberCommandEntry emberCommandTable[]
262
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandInterpreter2Configuration#
uint8_t emberCommandInterpreter2Configuration
Configuration byte.
267
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Function Documentation#
emberCommandReaderSetDefaultBase#
void emberCommandReaderSetDefaultBase (uint8_t base)
N/A | base |
375
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandActionHandler#
void emberCommandActionHandler (const CommandAction action)
N/A | action |
The application may implement this handler. To override the default handler, define EMBER_APPLICATION_HAS_COMMAND_ACTION_HANDLER in the CONFIGURATION_HEADER.
381
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandErrorHandler#
void emberCommandErrorHandler (EmberCommandStatus status)
N/A | status |
The application may implement this handler. To override the default handler, define EMBER_APPLICATION_HAS_COMMAND_ERROR_HANDLER in the CONFIGURATION_HEADER. Defining this will also remove the help functions emberPrintCommandUsage(), emberPrintCommandUsageNotes(), and emberPrintCommandTable().
388
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberPrintCommandUsage#
void emberPrintCommandUsage (EmberCommandEntry * entry)
N/A | entry |
389
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberPrintCommandUsageNotes#
void emberPrintCommandUsageNotes (void )
N/A |
390
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberPrintCommandTable#
void emberPrintCommandTable (void )
N/A |
391
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandClearBuffer#
void emberCommandClearBuffer (void )
N/A |
392
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandReaderInit#
void emberCommandReaderInit (void )
Initialize the command interpreter.
N/A |
396
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberProcessCommandString#
bool emberProcessCommandString (uint8_t * input, uint8_t sizeOrPort)
Process the given string as a command.
N/A | input | |
N/A | sizeOrPort |
400
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandInterpreterBusy#
bool emberCommandInterpreterBusy (void )
Returns true interpreter is reading a command.
N/A |
433
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
Macro Definition Documentation#
MAX_TOKEN_COUNT#
#define MAX_TOKEN_COUNTValue:
(EMBER_MAX_COMMAND_ARGUMENTS + 1)
132
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandEntryAction#
#define emberCommandEntryActionValue:
(name, action, argumentTypes, description)
213
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandEntryActionWithDetails#
#define emberCommandEntryActionWithDetailsValue:
(name, action, argumentTypes, description, argumentDescriptionArray)
220
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandEntrySubMenu
#define emberCommandEntrySubMenuValue:
(name, subMenu, description)
224
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandEntryTerminator#
#define emberCommandEntryTerminatorValue:
()
228
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO#
#define EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHOValue:
(0x01)
269
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberProcessCommandInput#
#define emberProcessCommandInputValue:
(port)
Process input coming in on the given serial port.
Returns
true if an end of line character was read. If the application uses a command line prompt, this indicates it is time to print the prompt.
void emberProcessCommandInput(uint8_t port);
410
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandInterpreterEchoOn#
#define emberCommandInterpreterEchoOnValue:
Turn echo of command line on.
415
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandInterpreterEchoOff#
#define emberCommandInterpreterEchoOffValue:
Turn echo of command line off.
421
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h
emberCommandInterpreterIsEchoOn#
#define emberCommandInterpreterIsEchoOnValue:
Returns true if echo is on, false otherwise.
427
of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h