diff --git a/firmware/project-firmware/usr/uInverter/cmd/cmd_uInverter.c b/firmware/project-firmware/usr/uInverter/cmd/cmd_uInverter.c index ab7d548..4ef2b66 100644 --- a/firmware/project-firmware/usr/uInverter/cmd/cmd_uInverter.c +++ b/firmware/project-firmware/usr/uInverter/cmd/cmd_uInverter.c @@ -15,6 +15,7 @@ static command_entry_t cmd_entry; // Defines help content displayed for this command // when user types "help" at command prompt static command_help_t cmd_help[] = { + { "stats ", "Print or Reset statistics"}, { "start", "Begin VSI output" }, { "stop", "End VSI output" }, { "freq ", "Set the uInverter frequency" }, @@ -72,7 +73,15 @@ int cmd_uInverter(int argc, char **argv) return CMD_SUCCESS; } + if (argc == 3 && STREQ("stats", argv[1])){ + if (STREQ("print", argv[2])) + return task_uInverter_stats_print() == SUCCESS ? CMD_SUCCESS : CMD_FAILURE; + if(STREQ("reset", argv[2])) + return task_uInverter_stats_reset() == SUCCESS ? CMD_SUCCESS : CMD_FAILURE; + } + + return CMD_INVALID_ARGUMENTS; } -#endif // APP_uInverter \ No newline at end of file +#endif // APP_uInverter diff --git a/firmware/project-firmware/usr/uInverter/task_uInverter.c b/firmware/project-firmware/usr/uInverter/task_uInverter.c index 8b44807..b895ed5 100644 --- a/firmware/project-firmware/usr/uInverter/task_uInverter.c +++ b/firmware/project-firmware/usr/uInverter/task_uInverter.c @@ -3,6 +3,7 @@ #include "usr/uInverter/task_uInverter.h" #include "sys/scheduler.h" #include "drv/pwm.h" +#include "drv/cpu_timer.h" #include // Scheduler TCB which holds task "context" @@ -20,7 +21,9 @@ int task_uInverter_init(void){ // Fill TCB with parameters scheduler_tcb_init(&tcb, task_uInverter_callback, - NULL, "vsi", TASK_UINVERTER_INTERVAL_USEC); + NULL, "uInverter", TASK_UINVERTER_INTERVAL_USEC); + + task_stats_enable(&tcb.stats); // Register task with scheduler return scheduler_tcb_register(&tcb); @@ -59,4 +62,14 @@ int task_uInverter_set_amplitude(double amplitude){ return SUCCESS; } +int task_uInverter_stats_print(){ + task_stats_print(&tcb.stats); + return SUCCESS; +} + +int task_uInverter_stats_reset(){ + task_stats_reset(&tcb.stats); + return SUCCESS; +} + #endif // APP_uInverter diff --git a/firmware/project-firmware/usr/uInverter/task_uInverter.h b/firmware/project-firmware/usr/uInverter/task_uInverter.h index 5863732..67342df 100644 --- a/firmware/project-firmware/usr/uInverter/task_uInverter.h +++ b/firmware/project-firmware/usr/uInverter/task_uInverter.h @@ -14,4 +14,7 @@ void task_uInverter_callback(void *arg); int task_uInverter_set_frequency(double freq); int task_uInverter_set_amplitude(double amplitude); -#endif // TASK_UINVERTER_H \ No newline at end of file +int task_uInverter_stats_print(); +int task_uInverter_stats_reset(); + +#endif // TASK_UINVERTER_H