mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Change command interpreter semantics.
This commit is contained in:
parent
49f726cf25
commit
ff8a7626d0
Binary file not shown.
|
@ -65,8 +65,12 @@
|
||||||
/* Utils includes. */
|
/* Utils includes. */
|
||||||
#include "CommandInterpreter.h"
|
#include "CommandInterpreter.h"
|
||||||
|
|
||||||
|
/* Dimensions the buffer into which input characters are placed. */
|
||||||
#define cmdMAX_INPUT_SIZE 20
|
#define cmdMAX_INPUT_SIZE 20
|
||||||
|
|
||||||
|
/* Dimensions the buffer into which string outputs can be placed. */
|
||||||
|
#define cmdMAX_OUTPUT_SIZE 1024
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
||||||
|
@ -75,9 +79,9 @@ long lSocket, lClientFd, lBytes, lAddrLen = sizeof( struct sockaddr_in );
|
||||||
struct sockaddr_in sLocalAddr;
|
struct sockaddr_in sLocalAddr;
|
||||||
struct sockaddr_in client_addr;
|
struct sockaddr_in client_addr;
|
||||||
const signed char *pcWelcomeMessage = "FreeRTOS command server - connection accepted.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
const signed char *pcWelcomeMessage = "FreeRTOS command server - connection accepted.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
||||||
const signed char *pcString;
|
|
||||||
signed char cInChar, cInputIndex;
|
signed char cInChar, cInputIndex;
|
||||||
signed char cInputString[ cmdMAX_INPUT_SIZE ];
|
static signed char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ];
|
||||||
|
portBASE_TYPE xReturned;
|
||||||
|
|
||||||
( void ) pvParameters;
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
@ -134,12 +138,12 @@ signed char cInputString[ cmdMAX_INPUT_SIZE ];
|
||||||
{
|
{
|
||||||
/* The input string was not a quit command.
|
/* The input string was not a quit command.
|
||||||
Pass the string to the command interpreter. */
|
Pass the string to the command interpreter. */
|
||||||
while( ( pcString = pcCmdIntProcessCommand( cInputString ) ) != NULL )
|
do
|
||||||
{
|
{
|
||||||
/* A string has been generated by the
|
xReturned = xCmdIntProcessCommand( cInputString, cOutputString, cmdMAX_OUTPUT_SIZE );
|
||||||
command interpreter. Send it. */
|
lwip_send( lClientFd, cOutputString, strlen( ( const char * ) cOutputString ), 0 );
|
||||||
lwip_send( lClientFd, pcString, strlen( ( const char * ) pcString ), 0 );
|
|
||||||
}
|
} while( xReturned != pdFALSE );
|
||||||
|
|
||||||
/* All the strings generated by the input
|
/* All the strings generated by the input
|
||||||
command have been sent. Clear the input
|
command have been sent. Clear the input
|
||||||
|
|
|
@ -122,11 +122,11 @@ static void prvCheckTimerCallback( xTimerHandle xTimer );
|
||||||
extern void lwIPAppsInit( void *pvArguments );
|
extern void lwIPAppsInit( void *pvArguments );
|
||||||
|
|
||||||
/* Callbacks to handle the command line commands defined by the xTaskStats and
|
/* Callbacks to handle the command line commands defined by the xTaskStats and
|
||||||
xRunTimeStats command definitions respectively. These functions are not
|
xRunTimeStats command definitions respectively. These functions are not
|
||||||
reentrant! They must be used from one task only - or at least by only one task
|
necessarily reentrant! They must be used from one task only - or at least by
|
||||||
at a time. */
|
only one task at a time. */
|
||||||
static const signed char *prvTaskStatsCommand( void );
|
static portBASE_TYPE prvTaskStatsCommand( signed char *pcWriteBuffer, size_t xWriteBufferLen );
|
||||||
static const signed char *prvRunTimeStatsCommand( void );
|
static portBASE_TYPE prvRunTimeStatsCommand( signed char *pcWriteBuffer, size_t xWriteBufferLen );
|
||||||
|
|
||||||
/* The string that latches the current demo status. */
|
/* The string that latches the current demo status. */
|
||||||
static char *pcStatusMessage = "All tasks running without error";
|
static char *pcStatusMessage = "All tasks running without error";
|
||||||
|
@ -316,70 +316,41 @@ unsigned long ulReturn;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static const signed char *prvTaskStatsCommand( void )
|
static portBASE_TYPE prvTaskStatsCommand( signed char *pcWriteBuffer, size_t xWriteBufferLen )
|
||||||
{
|
{
|
||||||
static signed char *pcReturn = NULL;
|
|
||||||
const char *const pcHeader = "Task State Priority Stack #\r\n************************************************\r\n";
|
const char *const pcHeader = "Task State Priority Stack #\r\n************************************************\r\n";
|
||||||
|
|
||||||
/* This is the callback function that is executed when the command line
|
configASSERT( pcWriteBuffer );
|
||||||
command defined by the xTaskStats structure is entered. This function
|
|
||||||
is called repeatedly until it returns NULL. It is therefore not re-entrant
|
|
||||||
and must not be called from more than one task - or at least - not from
|
|
||||||
more than one task at the same time. */
|
|
||||||
if( pcReturn == NULL )
|
|
||||||
{
|
|
||||||
/* Generate a table of task state. */
|
|
||||||
pcReturn = pcLwipAppsBlockingGetTxBuffer();
|
|
||||||
if( pcReturn != NULL )
|
|
||||||
{
|
|
||||||
strcpy( pcReturn, pcHeader );
|
|
||||||
vTaskList( pcReturn + strlen( pcHeader ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This command only returns one string, so the second time it is
|
|
||||||
called it just resets itself and returns NULL to say no more strings
|
|
||||||
are going to be generated. */
|
|
||||||
pcReturn = NULL;
|
|
||||||
vLwipAppsReleaseTxBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pcReturn;
|
/* This function assumes the buffer length is adequate. */
|
||||||
|
( void ) xWriteBufferLen;
|
||||||
|
|
||||||
|
/* Generate a table of task stats. */
|
||||||
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
|
vTaskList( pcWriteBuffer + strlen( pcHeader ) );
|
||||||
|
|
||||||
|
/* There is no more data to return after this single string, so return
|
||||||
|
pdFALSE. */
|
||||||
|
return pdFALSE;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static const signed char *prvRunTimeStatsCommand( void )
|
static portBASE_TYPE prvRunTimeStatsCommand( signed char *pcWriteBuffer, size_t xWriteBufferLen )
|
||||||
{
|
{
|
||||||
static signed char *pcReturn = NULL;
|
|
||||||
const char * const pcHeader = "Task Abs Time % Time\r\n****************************************\r\n";
|
const char * const pcHeader = "Task Abs Time % Time\r\n****************************************\r\n";
|
||||||
|
|
||||||
/* This is the callback function that is executed when the command line
|
configASSERT( pcWriteBuffer );
|
||||||
command defined by the xRunTimeStats structure is entered. This function
|
|
||||||
is called repeatedly until it returns NULL. It is therefore not re-entrant
|
|
||||||
and must not be called from more than one task - or at least - not from
|
|
||||||
more than one task at the same time. */
|
|
||||||
|
|
||||||
if( pcReturn == NULL )
|
/* This function assumes the buffer length is adequate. */
|
||||||
{
|
( void ) xWriteBufferLen;
|
||||||
/* Generate a table of run time stats. */
|
|
||||||
pcReturn = pcLwipAppsBlockingGetTxBuffer();
|
|
||||||
if( pcReturn != NULL )
|
|
||||||
{
|
|
||||||
strcpy( pcReturn, pcHeader );
|
|
||||||
vTaskGetRunTimeStats( pcReturn + strlen( pcHeader ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This command only returns one string, so the second time it is
|
|
||||||
called it just resets itself and returns NULL to say no more strings
|
|
||||||
are going to be generated. */
|
|
||||||
pcReturn = NULL;
|
|
||||||
vLwipAppsReleaseTxBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pcReturn;
|
/* Generate a table of task stats. */
|
||||||
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
|
vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );
|
||||||
|
|
||||||
|
/* There is no more data to return after this single string, so return
|
||||||
|
pdFALSE. */
|
||||||
|
return pdFALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue