2009-12-10 15:44:55 +00:00
|
|
|
/*
|
2013-05-11 06:08:17 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
2009-12-10 15:44:55 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2009-12-10 15:44:55 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2009-12-10 15:44:55 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-06-28 06:29:04 +00:00
|
|
|
* @file shell.h
|
|
|
|
* @brief Simple CLI shell header.
|
|
|
|
*
|
2009-12-10 15:44:55 +00:00
|
|
|
* @addtogroup SHELL
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SHELL_H_
|
|
|
|
#define _SHELL_H_
|
|
|
|
|
|
|
|
/**
|
2011-09-23 15:48:55 +00:00
|
|
|
* @brief Shell maximum input line length.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
|
|
|
#if !defined(SHELL_MAX_LINE_LENGTH) || defined(__DOXYGEN__)
|
|
|
|
#define SHELL_MAX_LINE_LENGTH 64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2011-09-23 15:48:55 +00:00
|
|
|
* @brief Shell maximum arguments per command.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
|
|
|
#if !defined(SHELL_MAX_ARGUMENTS) || defined(__DOXYGEN__)
|
|
|
|
#define SHELL_MAX_ARGUMENTS 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2011-09-23 15:48:55 +00:00
|
|
|
* @brief Command handler function type.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
2012-05-08 17:09:20 +00:00
|
|
|
typedef void (*shellcmd_t)(BaseSequentialStream *chp, int argc, char *argv[]);
|
2009-12-10 15:44:55 +00:00
|
|
|
|
|
|
|
/**
|
2011-09-23 15:48:55 +00:00
|
|
|
* @brief Custom command entry type.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
const char *sc_name; /**< @brief Command name. */
|
|
|
|
shellcmd_t sc_function; /**< @brief Command function. */
|
|
|
|
} ShellCommand;
|
|
|
|
|
|
|
|
/**
|
2011-09-23 15:48:55 +00:00
|
|
|
* @brief Shell descriptor type.
|
2009-12-10 15:44:55 +00:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2012-05-08 17:09:20 +00:00
|
|
|
BaseSequentialStream *sc_channel; /**< @brief I/O channel associated
|
2009-12-10 15:44:55 +00:00
|
|
|
to the shell. */
|
|
|
|
const ShellCommand *sc_commands; /**< @brief Shell extra commands
|
|
|
|
table. */
|
|
|
|
} ShellConfig;
|
|
|
|
|
2011-09-23 15:48:55 +00:00
|
|
|
#if !defined(__DOXYGEN__)
|
2009-12-10 15:44:55 +00:00
|
|
|
extern EventSource shell_terminated;
|
2011-09-23 15:48:55 +00:00
|
|
|
#endif
|
2009-12-10 15:44:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void shellInit(void);
|
|
|
|
Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio);
|
2011-09-17 21:06:25 +00:00
|
|
|
Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
|
|
|
|
size_t size, tprio_t prio);
|
2012-05-08 17:09:20 +00:00
|
|
|
bool_t shellGetLine(BaseSequentialStream *chp, char *line, unsigned size);
|
2009-12-10 15:44:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SHELL_H_ */
|
|
|
|
|
|
|
|
/** @} */
|