Commit 5730641a authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

create another way to add functions

parent f6296713
Pipeline #3825 canceled with stages
in 1 minute and 46 seconds
......@@ -10,60 +10,17 @@
/***************************** Include Files **********************************/
#include "fpga_device.h"
/************************** Functions Prototype *******************************/
static int cmd_fpga_status (char *params);
/******************************** Structs *************************************/
struct command_entry commands_list_fpga_device[] = {
{ .cmd_name = "status", .cmd_func = cmd_fpga_status, .cmd_help_string = "Get all the information about FPGA convention\n", .cmd_params = "<all>"}
};
/******************************* Functions ************************************/
/******************************************************************************/
/**
* This function seach for subcommands related with FPGA information
*
******************************************************************************/
static void cmd_fpga (char *params) {
struct command_entry *entry;
char *cmd_start_p = params;
int ret;
int cmd_len;
if (!params || !(*params)) {
printf("Please provide subcommand for the Gateware command\n");
cmd_help("gateware");
return -ENOENT;
}
params = strchr(params, ' ');
if (params) {
cmd_len = params - cmd_start_p;
/* skip spaces for params */
while (*params && (*params == ' ')) {
params++;
}
} else {
cmd_len = strlen(cmd_start_p);
}
entry = commands_list_fpga_device;
while (entry && entry->cmd_name) {
if (cmd_len == strlen(entry->cmd_name) && !strncmp(entry->cmd_name, cmd_start_p, cmd_len)) {
ret = entry->cmd_func(params);
break;
}
entry++;
}
if (!(entry && entry->cmd_name)) {
printf("Commad \"%s\" not found\n", cmd_start_p);
ret = -ENOENT;
}
return ret;
}
static void cmd_fpga_status(char *params) {
static int cmd_fpga_status(char *params) {
/*{
struct tm build_date_s;
......@@ -124,5 +81,52 @@ static void cmd_fpga_status(char *params) {
return;
*/
printf("FPGA STATUS TO BE DONE");
return;
return 0;
}
/******************************************************************************/
/**
* This function seach for subcommands related with FPGA information
*
******************************************************************************/
int cmd_fpga (char *params) {
struct command_entry *entry;
char *cmd_start_p = params;
int ret;
int cmd_len;
if (!params || !(*params)) {
printf("Please provide subcommand for the Gateware command\n");
cmd_help("gateware");
return -ENOENT;
}
params = strchr(params, ' ');
if (params) {
cmd_len = params - cmd_start_p;
/* skip spaces for params */
while (*params && (*params == ' ')) {
params++;
}
} else {
cmd_len = strlen(cmd_start_p);
}
entry = commands_list_fpga_device;
while (entry && entry->cmd_name) {
if (cmd_len == strlen(entry->cmd_name) && !strncmp(entry->cmd_name, cmd_start_p, cmd_len)) {
ret = entry->cmd_func(params);
break;
}
entry++;
}
if (!(entry && entry->cmd_name)) {
printf("Commad \"%s\" not found\n", cmd_start_p);
ret = -ENOENT;
}
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment