Commit c85e9413 authored by Alessandro Rubini's avatar Alessandro Rubini

general: gui/shell return integer

This is a step towards profiling. The functions being polled return
whether or not they did actually work.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c3c9d67a
...@@ -35,7 +35,7 @@ int env_set(const char *var, const char *value); ...@@ -35,7 +35,7 @@ int env_set(const char *var, const char *value);
void env_init(void); void env_init(void);
int shell_exec(const char *buf); int shell_exec(const char *buf);
void shell_interactive(void); int shell_interactive(void);
int shell_boot_script(void); int shell_boot_script(void);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
# define is_wr_node 1 # define is_wr_node 1
#endif #endif
void wrc_mon_gui(void); int wrc_mon_gui(void);
void shell_init(void); void shell_init(void);
int wrc_log_stats(void); int wrc_log_stats(void);
......
...@@ -81,7 +81,7 @@ static int wrc_mon_status(void) ...@@ -81,7 +81,7 @@ static int wrc_mon_status(void)
return 1; return 1;
} }
void wrc_mon_gui(void) int wrc_mon_gui(void)
{ {
static uint32_t last_jiffies; static uint32_t last_jiffies;
static uint32_t last_servo_count; static uint32_t last_servo_count;
...@@ -100,7 +100,7 @@ void wrc_mon_gui(void) ...@@ -100,7 +100,7 @@ void wrc_mon_gui(void)
last_jiffies = timer_get_tics() - 1 - wrc_ui_refperiod; last_jiffies = timer_get_tics() - 1 - wrc_ui_refperiod;
if (time_before(timer_get_tics(), last_jiffies + wrc_ui_refperiod) if (time_before(timer_get_tics(), last_jiffies + wrc_ui_refperiod)
&& last_servo_count == s->update_count) && last_servo_count == s->update_count)
return; return 0;
last_jiffies = timer_get_tics(); last_jiffies = timer_get_tics();
last_servo_count = s->update_count; last_servo_count = s->update_count;
...@@ -130,7 +130,7 @@ void wrc_mon_gui(void) ...@@ -130,7 +130,7 @@ void wrc_mon_gui(void)
if (!WR_DSPOR(ppi)->wrModeOn) { if (!WR_DSPOR(ppi)->wrModeOn) {
wrc_mon_std_servo(); wrc_mon_std_servo();
return; return 1;
} }
switch (ptp_mode) { switch (ptp_mode) {
...@@ -174,7 +174,7 @@ void wrc_mon_gui(void) ...@@ -174,7 +174,7 @@ void wrc_mon_gui(void)
} }
if (wrc_mon_status() == 0) if (wrc_mon_status() == 0)
return; return 1;
cprintf(C_GREY, "Servo state: "); cprintf(C_GREY, "Servo state: ");
cprintf(C_WHITE, "%s\n", s->servo_state_name); cprintf(C_WHITE, "%s\n", s->servo_state_name);
...@@ -247,7 +247,7 @@ void wrc_mon_gui(void) ...@@ -247,7 +247,7 @@ void wrc_mon_gui(void)
pp_printf("--"); pp_printf("--");
return; return 1;
} }
static inline void cprintf_ti(int color, struct TimeInternal *ti) static inline void cprintf_ti(int color, struct TimeInternal *ti)
...@@ -301,6 +301,9 @@ int wrc_log_stats(void) ...@@ -301,6 +301,9 @@ int wrc_log_stats(void)
&((struct wr_data *)ppi->ext_data)->servo_state; &((struct wr_data *)ppi->ext_data)->servo_state;
static uint32_t last_jiffies; static uint32_t last_jiffies;
if (!wrc_stat_running)
return 0;
if (!last_jiffies) if (!last_jiffies)
last_jiffies = timer_get_tics() - 1 - wrc_ui_refperiod; last_jiffies = timer_get_tics() - 1 - wrc_ui_refperiod;
/* stats update condition for Slave mode */ /* stats update condition for Slave mode */
...@@ -363,5 +366,5 @@ int wrc_log_stats(void) ...@@ -363,5 +366,5 @@ int wrc_log_stats(void)
pp_printf("\n"); pp_printf("\n");
return 0; return 1;
} }
...@@ -128,7 +128,7 @@ void shell_init() ...@@ -128,7 +128,7 @@ void shell_init()
state = SH_PROMPT; state = SH_PROMPT;
} }
void shell_interactive() int shell_interactive()
{ {
int c; int c;
switch (state) { switch (state) {
...@@ -137,13 +137,13 @@ void shell_interactive() ...@@ -137,13 +137,13 @@ void shell_interactive()
cmd_pos = 0; cmd_pos = 0;
cmd_len = 0; cmd_len = 0;
state = SH_INPUT; state = SH_INPUT;
break; return 1;
case SH_INPUT: case SH_INPUT:
c = uart_read_byte(); c = uart_read_byte();
if (c < 0) if (c < 0)
return; return 0;
if (c == 27 || ((current_key & ESCAPE_FLAG) && c == 91)) if (c == 27 || ((current_key & ESCAPE_FLAG) && c == 91))
current_key = ESCAPE_FLAG; current_key = ESCAPE_FLAG;
...@@ -201,14 +201,15 @@ void shell_interactive() ...@@ -201,14 +201,15 @@ void shell_interactive()
} }
current_key = 0; current_key = 0;
} }
break; return 1;
case SH_EXEC: case SH_EXEC:
cmd_buf[cmd_len] = 0; cmd_buf[cmd_len] = 0;
_shell_exec(); _shell_exec();
state = SH_PROMPT; state = SH_PROMPT;
break; return 1;
} }
return 0;
} }
const char *fromhex(const char *hex, int *v) const char *fromhex(const char *hex, int *v)
......
...@@ -119,21 +119,20 @@ static int wrc_check_link(void) ...@@ -119,21 +119,20 @@ static int wrc_check_link(void)
int wrc_man_phase = 0; int wrc_man_phase = 0;
static void ui_update(void) static int ui_update(void)
{ {
int ret;
if (wrc_ui_mode == UI_GUI_MODE) { if (wrc_ui_mode == UI_GUI_MODE) {
wrc_mon_gui(); ret = wrc_mon_gui();
if (uart_read_byte() == 27 || wrc_ui_refperiod == 0) { if (uart_read_byte() == 27 || wrc_ui_refperiod == 0) {
shell_init(); shell_init();
wrc_ui_mode = UI_SHELL_MODE; wrc_ui_mode = UI_SHELL_MODE;
} }
} else { } else {
shell_interactive(); ret = shell_interactive();
} }
/* Stats is asynchronous now. It's not a different mode, but a flag */ return ret;
if (wrc_stat_running)
wrc_log_stats();
} }
/* initialize functions to be called after reset in check_reset function */ /* initialize functions to be called after reset in check_reset function */
...@@ -196,6 +195,7 @@ int main(void) ...@@ -196,6 +195,7 @@ int main(void)
} }
ui_update(); ui_update();
wrc_log_stats();
wrc_ptp_update(); wrc_ptp_update();
spll_update(); spll_update();
check_stack(); check_stack();
......
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