增加所有文件
This commit is contained in:
88
middleware/CLI/include/CLI.h
Normal file
88
middleware/CLI/include/CLI.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* FreeRTOS+CLI V1.0.4
|
||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef CLI_H_
|
||||
#define CLI_H_
|
||||
|
||||
#include <compiler.h>
|
||||
#include <types.h>
|
||||
|
||||
#define CLI_FALSE ( ( int ) 0 )
|
||||
#define CLI_TRUE ( ( int ) 1 )
|
||||
#define CLI_MAX_ARGS 16
|
||||
|
||||
/* The prototype to which callback functions used to process command line
|
||||
commands must comply. pcWriteBuffer is a buffer into which the output from
|
||||
executing the command can be written, xWriteBufferLen is the length, in bytes of
|
||||
the pcWriteBuffer buffer, and pcCommandString is the entire string as input by
|
||||
the user (from which parameters can be extracted).*/
|
||||
typedef int (*pdCOMMAND_LINE_CALLBACK)( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/* The structure that defines command line commands. A command line command
|
||||
should be defined by declaring a const structure of this type. */
|
||||
typedef struct xCOMMAND_LINE_INPUT
|
||||
{
|
||||
const char * const pcCommand; /* The command that causes pxCommandInterpreter to be executed. For example "help". Must be all lower case. */
|
||||
const char * const pcHelpString; /* String that describes how to use the command. Should start with the command itself, and end with "\r\n". For example "help: Returns a list of all the commands\r\n". */
|
||||
const pdCOMMAND_LINE_CALLBACK pxCommandInterpreter; /* A pointer to the callback function that will return the output generated by the command. */
|
||||
struct xCOMMAND_LINE_INPUT *pxNext; /* next command */
|
||||
} CLI_Command_Definition_t;
|
||||
|
||||
/* For backward compatibility. */
|
||||
#define xCommandLineInput CLI_Command_Definition_t
|
||||
|
||||
extern int CLITokenizeCommand(const char *pcCommandString, char *argv[]);
|
||||
|
||||
typedef int (*CLI_CMD_CALLBACK)(int argc, char *argv[]);
|
||||
|
||||
#define CLI_CMD(name, help, func) \
|
||||
int _cli_inter_##func (char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString) \
|
||||
{ \
|
||||
int argc = 0; \
|
||||
char *argv[CLI_MAX_ARGS]; \
|
||||
argc = CLITokenizeCommand(pcCommandString, argv); \
|
||||
return func(argc, argv); \
|
||||
} \
|
||||
__USED const CLI_Command_Definition_t _cli_cmd_##func __SECTION(".commands") = \
|
||||
{ name, help, _cli_inter_##func, NULL}
|
||||
|
||||
/*
|
||||
* Init CLI, register CLI commands.
|
||||
*/
|
||||
int CLIInit(void);
|
||||
|
||||
/*
|
||||
* CLI Write Data.
|
||||
*/
|
||||
void CLIWriteData(const char *data, size_t len);
|
||||
|
||||
/*
|
||||
* console command handler entry.
|
||||
*/
|
||||
void CLICommandHandler(char cRxedChar);
|
||||
|
||||
#endif /* CLI_H_ */
|
||||
Reference in New Issue
Block a user