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