-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.h
94 lines (63 loc) · 1.74 KB
/
shell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* shell.h
*
* Created on: 29 mar 2016
* Author: MateuszPiesta
*/
#ifndef MODULES_SHELL_SHELL_H_
#define MODULES_SHELL_SHELL_H_
#include "shell_conf.h"
#include <stdint.h>
#include <stddef.h>
#include "FreeRTOS_CLI.h"
#define SHELL_CMD_VARIABLE_PARAM_NR -1
/**
* Prototype for shell_write function.
* str - string to be written
* len - string length
* param - generic pointer to pass/ret user's data to/from function */
typedef uint8_t (*shell_write_t)(const char* str, size_t len, void* param);
/**
* Prototype for shell_read function
* str - string read
* param - generic pointer to pass/ret user's data to/from function
*/
typedef uint8_t (*shell_read_t)(char* str,uint32_t* len, void* param);
typedef CLI_Command_Definition_t shell_cmd_t;
typedef enum {
AUTH_IN_PROGRESS = 1,
AUTH_PASSED = 2
}auth_action;
typedef struct _shell {
void* hist_queue;
char* line_prompt;
char* line_buff;
uint32_t line_buff_pos;
//uint32_t line_buff_current_size;
size_t line_buff_size;
shell_write_t write;
shell_read_t read;
const char *bs_code;
const char *newline_code;
const char *arrowl_code;
const char *arrowr_code;
const char *arrowu_code;
const char *arrowd_code;
void* param;
} shell_t;
typedef enum{
SHELL_OK=0,
SHELL_ERR_GEN=1,
SHELL_ERR_TAB_FULL=2,
SHELL_ERR_SPACE=3,
SHELL_ERR_MEM=4,
}sherr_t;
sherr_t shell_Init(shell_t* shell, size_t linebuf_len);
void shell_InitPlatform(shell_t* shell);
uint8_t shell_RegisterCmd( const shell_cmd_t * const pxCommandToRegister );
void shell_RegisterIOFunctions(shell_t* shell,
shell_write_t write,
shell_read_t read);
void shell_RunPeriodic(shell_t* shell);
void shell_PassParam(shell_t* shell,void* param, size_t param_len);
#endif /* MODULES_SHELL_SHELL_H_ */