Skip to content

Commit

Permalink
[finsh] feat: add finsh thread entry hook
Browse files Browse the repository at this point in the history
Signed-off-by: Shell <[email protected]>
  • Loading branch information
polarvid authored and mysterywolf committed Mar 22, 2024
1 parent 881c810 commit 22106bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,28 @@ static void shell_push_history(struct finsh_shell *shell)
}
#endif

#ifdef RT_USING_HOOK
static void (*_finsh_thread_entry_hook)(void);

/**
* @ingroup finsh
*
* @brief This function set a hook function at the entry of finsh thread
*
* @param hook the function point to be called
*/
void finsh_thread_entry_sethook(void (*hook)(void))
{
_finsh_thread_entry_hook = hook;
}
#endif /* RT_USING_HOOK */

static void finsh_thread_entry(void *parameter)
{
int ch;

RT_OBJECT_HOOK_CALL(_finsh_thread_entry_hook, ());

/* normal is echo mode */
#ifndef FINSH_ECHO_DISABLE_DEFAULT
shell->echo_mode = 1;
Expand Down
4 changes: 4 additions & 0 deletions components/finsh/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode);
const char *finsh_get_password(void);
#endif

#ifdef RT_USING_HOOK
void finsh_thread_entry_sethook(void (*hook)(void));
#endif /* RT_USING_HOOK */

#endif

0 comments on commit 22106bb

Please sign in to comment.