24
24
#define BUTTON_FLAG_FILE_CONFIGURED 1u<<2
25
25
26
26
uint8_t button_flags [BP_BUTT_MAX - 1 ];
27
- char button_script_files [BP_BUTT_MAX - 1 ][BP_FILENAME_MAX + 1 ];
27
+ char button_script_files [BP_BUTT_MAX - 1 ][BP_FILENAME_MAX ];
28
28
29
29
typedef struct {
30
30
const char * verb ;
@@ -48,8 +48,13 @@ static const char * const usage[]= {
48
48
};
49
49
50
50
static const struct ui_help_options options []= {
51
- //{1,"", T_HELP_FLASH}, //flash command help
52
- // {0,"-f",T_HELP_FLASH_FILE_FLAG}, //file to read/write/verify
51
+ {1 ,"" , T_HELP_BUTTON },
52
+ {0 ,"short" ,T_HELP_BUTTON_SHORT },
53
+ {0 ,"long" ,T_HELP_BUTTON_LONG },
54
+ {0 ,"-f" ,T_HELP_BUTTON_FILE },
55
+ {0 ,"-d" ,T_HELP_BUTTON_HIDE },
56
+ {0 ,"-e" ,T_HELP_BUTTON_EXIT },
57
+ {0 ,"-h" ,T_HELP_FLAG },
53
58
};
54
59
55
60
void button_scr_handler (struct command_result * res ){
@@ -80,9 +85,9 @@ void button_scr_handler(struct command_result *res){
80
85
}
81
86
82
87
//grab the file name, error if none
83
- char button_script_file [BP_FILENAME_MAX + 1 ];
88
+ char button_script_file [BP_FILENAME_MAX ];
84
89
command_var_t arg ;
85
- if (!cmdln_args_find_flag_string ('f' ,& arg , BP_FILENAME_MAX , button_script_file )){
90
+ if (!cmdln_args_find_flag_string ('f' ,& arg , BP_FILENAME_MAX - 1 , button_script_file )){
86
91
printf ("Specify a script file with the -f flag (-f script.scr)\r\n" );
87
92
ui_help_show (true,usage ,count_of (usage ), & options [0 ],count_of (options ) );
88
93
return ;
@@ -104,7 +109,7 @@ void button_scr_handler(struct command_result *res){
104
109
button_flags [button_code - 1 ]|=BUTTON_FLAG_FILE_CONFIGURED ;
105
110
106
111
//copy to button press type array
107
- memcpy (button_script_files [button_code - 1 ], button_script_file , BP_FILENAME_MAX );
112
+ memcpy (button_script_files [button_code - 1 ], button_script_file , BP_FILENAME_MAX - 1 );
108
113
printf ("Button script file set to '%s'\r\n" , button_script_file );
109
114
110
115
//set other flag options
0 commit comments