123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef _H_CLIFACE_
- #define _H_CLIFACE_
- #include "hal_mcu.h"
- #include <string.h>
- #define CLI_ERR(...)
- #define CLI_TRC(...)
- #define CLI_INF(...)
- #define CLI_STR_COMPARE(s0, s1) strcmp((const char *)(s0), (const char *)(s1))
- #define CLI_NULL_CHECK(ptr) \
- if (NULL == (ptr)) \
- {\
- CLI_ERR( \
- "[CLI] NULL Pointer\n"); \
- \
- return 0xffff; \
- }
- #define AT_CMD
-
- #define CLI_IS_WHITE_SPACE(ch) ((' ' == (ch)) || ('\t' == (ch)))
- #ifdef AT_CMD
- #define CLI_IS_CMD_SEPARATOR(ch) (('=' == (ch)) || (',' == (ch)) || ('\r' == (ch)) || ('\n' == (ch)))
- #else
- #define CLI_IS_CMD_SEPARATOR(ch) ((' ' == (ch)) || ('\t' == (ch)) || ('\r' == (ch)) || ('\n' == (ch)))
- #endif
-
- #define CLI_MAX_ARGS 16
- #define CLI_strlen(s) strlen((const char*)s)
- typedef uint16_t (* CLI_CMD_HANDLER)
- (
- uint32_t argc,
- uint8_t * argv[]
- ) ;
- typedef struct _cli_command
- {
-
- const uint8_t * cmd;
-
- const uint8_t * desc;
-
- const CLI_CMD_HANDLER cmd_hdlr;
- } CLI_COMMAND;
- uint16_t CLI_init
- (
- void
- );
- uint16_t CLI_process_line
- (
- uint8_t * buffer,
- uint32_t buffer_len,
- CLI_COMMAND * cmd_list,
- uint32_t cmd_count
- );
- int32_t CLI_strtoi
- (
- uint8_t *data,
- uint16_t data_length,
- uint8_t base
- );
- uint16_t CLI_strtoarray
- (
- uint8_t * data,
- uint16_t data_length,
- uint8_t * output_array,
- uint16_t output_array_len
- );
- uint16_t CLI_strtoarray_le
- (
- uint8_t * data,
- uint16_t data_length,
- uint8_t * output_array,
- uint16_t output_array_len
- );
- #endif
|