Synergy Software Package User's Manual

RTOS-integrated Console Framework. More...

Data Structures

struct  sf_console_instance_ctrl_t
 

Macros

#define SF_CONSOLE_CODE_VERSION_MAJOR   (2U)
 

Functions

ssp_err_t SF_CONSOLE_Open (sf_console_ctrl_t *const p_api_ctrl, sf_console_cfg_t const *const p_cfg)
 Initialize console framework and open low-level communication driver. More...
 
ssp_err_t SF_CONSOLE_Close (sf_console_ctrl_t *const p_api_ctrl)
 Close the communications driver. More...
 
ssp_err_t SF_CONSOLE_Parse (sf_console_ctrl_t *const p_api_ctrl, sf_console_menu_t const *const p_menu, uint8_t const *const p_input, uint32_t const bytes)
 Looks for input string in menu, and calls callback function if found. More...
 
ssp_err_t SF_CONSOLE_Prompt (sf_console_ctrl_t *const p_api_ctrl, sf_console_menu_t const *const p_menu, UINT const timeout)
 Prompt the user to input a command. More...
 
ssp_err_t SF_CONSOLE_Read (sf_console_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const bytes, uint32_t const timeout)
 Reads data into the destination byte by byte and echos input to the console. More...
 
ssp_err_t SF_CONSOLE_Write (sf_console_ctrl_t *const p_api_ctrl, uint8_t const *const p_src, uint32_t const timeout)
 Write a NULL terminated string to the console. More...
 
ssp_err_t SF_CONSOLE_ArgumentFind (uint8_t const *const p_arg, uint8_t const *const p_str, int32_t *const p_index, int32_t *const p_data)
 Finds a command line argument in an input string and returns the index of the character immediately following the argument and any string numbers converted to integers. More...
 
void SF_CONSOLE_CallbackNextMenu (sf_console_callback_args_t *p_args)
 Callback provided to continue parsing the next menu down. More...
 
ssp_err_t SF_CONSOLE_VersionGet (ssp_version_t *const p_version)
 Console version get function. More...
 

Detailed Description

RTOS-integrated Console Framework.

This is a ThreadX aware console framework implemented using the SSP communications framework.

Macro Definition Documentation

◆ SF_CONSOLE_CODE_VERSION_MAJOR

#define SF_CONSOLE_CODE_VERSION_MAJOR   (2U)

Version of code that implements the API defined in this file

Function Documentation

◆ SF_CONSOLE_ArgumentFind()

ssp_err_t SF_CONSOLE_ArgumentFind ( uint8_t const *const  p_arg,
uint8_t const *const  p_str,
int32_t *const  p_index,
int32_t *const  p_data 
)

Finds a command line argument in an input string and returns the index of the character immediately following the argument and any string numbers converted to integers.

Return values
SSP_SUCCESSArgument found successfully
SSP_ERR_ASSERTIONp_arg or p_str is NULL
SSP_ERR_INTERNALString passed after parsing command is NULL_CODE.
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Search for first letter match at beginning of word.

If the input string matches the input argument, store the index of the character following the argument in p_index and the data at that index in p_data. Then return.

◆ SF_CONSOLE_CallbackNextMenu()

void SF_CONSOLE_CallbackNextMenu ( sf_console_callback_args_t p_args)

Callback provided to continue parsing the next menu down.

Parameters
[in]p_argsPointer to callback arguments to use in the next menu.

Next level menu is passed in as the user context parameter

Update current menu.

Check to see if the next menu command was input in the remaining string.

◆ SF_CONSOLE_Close()

ssp_err_t SF_CONSOLE_Close ( sf_console_ctrl_t *const  p_api_ctrl)

Close the communications driver.

Return values
SSP_SUCCESSConsole successfully closed
SSP_ERR_ASSERTIONPointer to control block is NULL
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Close UART driver

◆ SF_CONSOLE_Open()

ssp_err_t SF_CONSOLE_Open ( sf_console_ctrl_t *const  p_api_ctrl,
sf_console_cfg_t const *const  p_cfg 
)

Initialize console framework and open low-level communication driver.

Return values
SSP_SUCCESSConsole channel is successfully opened
SSP_ERR_ASSERTIONParameter check failed for one of the following : -Pointer to the control block is NULL -Pointer to the config block is NULL -Pointer p_cfg->p_initial_menu is NULL -Pointer p_cfg->p_comms is NULL -Pointer p_cfg->p_comms->p_api is NULL -Pointer p_cfg->p_comms->p_api->open is NULL
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Open UART driver

Store echo configuration and initial menu in control block

Prompt for input autostart is true

◆ SF_CONSOLE_Parse()

ssp_err_t SF_CONSOLE_Parse ( sf_console_ctrl_t *const  p_api_ctrl,
sf_console_menu_t const *const  p_menu,
uint8_t const *const  p_input,
uint32_t const  bytes 
)

Looks for input string in menu, and calls callback function if found.

Return values
SSP_SUCCESSData parsed successfully, command found and callback called.
SSP_ERR_UNSUPPORTEDCommand not found in the current menu.
SSP_ERR_ASSERTIONOne or more input parameter pointers are invalid.
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Print help menu if help command is entered

Go back one menu if previous menu command is entered.

Go back to root menu if root menu command is entered.

Look for matching commands, call callback if command found.

◆ SF_CONSOLE_Prompt()

ssp_err_t SF_CONSOLE_Prompt ( sf_console_ctrl_t *const  p_api_ctrl,
sf_console_menu_t const *const  p_menu,
UINT const  timeout 
)

Prompt the user to input a command.

Return values
SSP_SUCCESSReceived valid command and called callback
SSP_ERR_ASSERTIONp_ctrl is NULL
SSP_ERR_UNSUPPORTEDCommand not found in the current menu.
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Update stored current menu pointer if a new pointer is specified.

Print menu name followed by ">" to prompt for user input.

Lock the console UART framework to reserve exclusive access until the command completes.

Note
Transmission is only locked while the menu name is printed and while the input command is non-zero in length. This allow debug messages to print from other threads while echo is off or no input command has been entered.

Wait for input

Parse input and call associated user callback.

Command is complete, so unlock comms reception.

◆ SF_CONSOLE_Read()

ssp_err_t SF_CONSOLE_Read ( sf_console_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_dest,
uint32_t const  bytes,
uint32_t const  timeout 
)

Reads data into the destination byte by byte and echos input to the console.

Return values
SSP_SUCCESSData read completed successfully
SSP_ERR_ASSERTIONParameter check failed for one of the following : -Pointer p_dest is NULL -Pointer to the control block is NULL -Pointer p_ctrl->p_comms is NULL -Pointer p_ctrl->p_comms->p_api is NULL -Pointer p_ctrl->p_comms->p_api->lock is NULL -Pointer p_ctrl->p_comms->p_api->unlock is NULL
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Lock the communications framework reception until carriage return is received.

Read one byte at a time, checking for carriage returns, backspace, delete, and escape codes.

Unlock the communications framework reception

◆ SF_CONSOLE_VersionGet()

ssp_err_t SF_CONSOLE_VersionGet ( ssp_version_t *const  p_version)

Console version get function.

Parameters
[in]p_versionVersion information stored here.
Return values
SSP_SUCCESSVersion stored in provided pointer.
SSP_ERR_ASSERTIONp_version was null.

Set version pointer

◆ SF_CONSOLE_Write()

ssp_err_t SF_CONSOLE_Write ( sf_console_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_src,
uint32_t const  timeout 
)

Write a NULL terminated string to the console.

Return values
SSP_SUCCESSData write completed successfully
SSP_ERR_ASSERTIONPointer to the control block is NULL
SSP_ERR_INVALID_SIZEIf length passed is zero or length passed is greater than 128U (max value).
Returns
See Common Error Codes or lower level drivers for other possible return codes.
Note
This function is reentrant for any channel.

Write null terminated string. Calculate the length. If it isn't longer than the maximum, write the entire string to the console.