Commit 66d4471d authored by Jakub Rzeszutko's avatar Jakub Rzeszutko Committed by Carles Cufi
Browse files

shell: add function checking shell readiness.



Tests with shell commands will fail if they are started
before the shell backend is initialized or started.
Adding API function: shell_ready indicating shell readiness.

Signed-off-by: default avatarJakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
parent 2b05f467
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1153,6 +1153,15 @@ int shell_set_root_cmd(const char *cmd);
 */
void shell_set_bypass(const struct shell *shell, shell_bypass_cb_t bypass);

/** @brief Get shell readiness to execute commands.
 *
 * @param[in] sh	Pointer to the shell instance.
 *
 * @retval true		Shell backend is ready to execute commands.
 * @retval false	Shell backend is not initialized or not started.
 */
bool shell_ready(const struct shell *sh);

/**
 * @brief Allow application to control text insert mode.
 * Value is modified atomically and the previous value is returned.
+7 −0
Original line number Diff line number Diff line
@@ -1690,6 +1690,13 @@ void shell_set_bypass(const struct shell *sh, shell_bypass_cb_t bypass)
	sh->ctx->bypass = bypass;
}

bool shell_ready(const struct shell *sh)
{
	__ASSERT_NO_MSG(sh);

	return state_get(sh) ==	SHELL_STATE_ACTIVE;
}

static int cmd_help(const struct shell *shell, size_t argc, char **argv)
{
	ARG_UNUSED(argc);