While verifying each mode for the Follow Along Logic Analyzer I did some cleanup to the global/mode command code:
struct _global_command_struct {
char command[MAX_COMMAND_LENGTH];
bool allow_hiz;
void (*func)(struct command_result* res);
uint32_t help_text;
};
struct _mode_command_struct {
char command[MAX_COMMAND_LENGTH];
void (*func)(struct command_result* res);
uint32_t description_text;
bool supress_fala_capture;
//bool supress_system_help; //do any actually use this? maybe remove this option
};
Global and mode commands shared a configuration struct, with mode commands piggybacking on some fields for unintended purposes. This made the update to Designated Initializers for Improved Readability really ugly.
- Split command struct into global commands (with optional help text) and local commands (with description, and fala enable/disable bit)
- Move all command structs into command_struct.h. Delete “opt-args.h” and command_attributes.h.
{ .command="ls", .allow_hiz=true, .func=&disk_ls_handler, .help_text=0x00 }, // ls T_CMDLN_LS
Global commands are now formatted with designated initializers.
{ .command="sle4442",
.func=&sle4442,
.description_text=T_HELP_SLE4442,
.supress_fala_capture=true
},
Mode commands were similarly formatted.
suppress_fala_capture:
- false: any time a command runs, the global fala capture happens. This can result in output even when there is no output (eg reading the help text)
- true: global fala is disabled. the command is expected to manage the capture itself (or none at all for long running processes like bridges)
// mode help handler (optional, set config in modes command struct)
if (cmdln_args_find_flag('h')) {
// mode commands must supply their own help text
result.help_flag = true;
// show auto short help
/*if (modes[system_config.mode].mode_commands[user_cmd_id].allow_hiz &&
(modes[system_config.mode].mode_commands[user_cmd_id].help_text != 0x00)) {
printf("%s%s%s\r\n",
ui_term_color_info(),
GET_T(modes[system_config.mode].mode_commands[user_cmd_id].help_text),
ui_term_color_reset());
return false;
} else { // let app know we requested help
result.help_flag = true;
}*/
}
There was some code in ui_process.c to fall back to a simple help text if available (similar to the global commands). This is unused (there is no way to actually use it) so it has been removed.
- All commands are expected to manage their own help (no change from the present)
Most commands have been reworked to manage their own FALA: samples will only be captured if bus activity actually happens, with graceful exit/cleanup on error.
Command text description and help have been updated where missing or incorrect.