The 'help' command from the CLI module doesn't work

Hallo!
I am using a FreeRTOS CLI implementation and the ‘help’ command doesn’t work, although other ‘integrated’ features do. I get the ‘Command not recognised…’ message when i send the ‘help’ to the device.
Other commands that I implemented work properly.
I did not register the ‘help’ command because I have seen that it doesn’t need to be included in the vRegisterCLICommands() function.
What I did:

  1. Created a CLIfuncs.c and .h for the implentation of the CLI commands.
  2. Found FreeRTOS_CLI.c and .h that reflect my version of the OS I am using, copied them and added to the project.
  3. Included the CLI_funcs in the main.c

It seems strange that the ‘help’ command doesn;t work, especially that other functionality is already there: I am getting a nice response when the CLI doesn’t understand the given command (“cOmmand not recognised…”), or when I try a command with wrong paramaters’ list.

Does anybody knwo why the help function doesn’t work? Do I have to register it in CLI_funcs.c? I can see it being implemented in FreeRTOS_CLI.c, I just can’t use it…

Thanks in advance for any answer.

I am including the code below.

My /include/CLI_funcs.h:

#ifndef CLIFUNCS_H_
#define CLIFUNCS_H_

#include "../include/FreeRTOS_CLI.h"
#include "FreeRTOS.h"
#include "string.h"
#include "../include/LWIPtasks.h" /* for the destination IP adress */

#define configCOMMAND_INT_MAX_OUTPUT_SIZE 500

BaseType_t xHelloWorldCommand( int8_t *pcWriteBuffer,
                             size_t xWriteBufferLen,
                             const int8_t *pcCommandString );
BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
void vUDPCommandConsoleTask(void* pvParamaters);

#endif /* CLIFUNCS_H_ */

My /include/CLI_funcs.c:

#include "CLIfuncs.h"

/* Commands' structs definitions **************************************************************************/

/* Structure that defines the "hallo world" command line command. */
static const CLI_Command_Definition_t HelloWorldCommandStruct =
{
    "hello",
    "hello: prints the hello world string\n",
	xHelloWorldCommand,
    0
};


/* Commands' declarations ***********************************************************************************/

/* Command that prints 'hallo world' when invoked */
BaseType_t xHelloWorldCommand( int8_t *pcWriteBuffer,
                             size_t xWriteBufferLen,
                             const int8_t *pcCommandString ){

	/* ignore the command - no parameters need to be addressed*/
	(void)pcCommandString;

	char hello_world[] = "Hello world\r\n ";

	memset( pcWriteBuffer, 0x00, xWriteBufferLen );	/* clear the buffer */
    strcpy(pcWriteBuffer,hello_world);

    /* single line output - no further output needed */
    return pdFALSE;

}


/* Register all the commands ***********************************************************/

void vRegisterCLICommands( void )
{
	/* Register all the command line commands defined immediately above. */
	FreeRTOS_CLIRegisterCommand( &HelloWorldCommandStruct );
}

/*-----------------------------------------------------------*/


/* Main task to start the UDP Connection and CLI **********************************************************/

/* Task that handles the CLI
 * - creates a connection
 * - toggles PJ4 when when a message recieved
 * in the loop
 *   - waits for the command
 *   - sends the command to cli interpreter
 *   - prints what the output of the command
 * */
void vUDPCommandConsoleTask(void* pvParamaters){

	
	/* creates a connection and bind the interface to */

        	 while(1)
	    	        {
		    	        while(netconn_recv(conn, &buf) != ERR_OK);

		    	        /* Get destination ip address and port*/
		    	        dst_addr = netbuf_fromaddr(buf);
		    	        dst_port = netbuf_fromport(buf);

		    	        /* Get the payload and length */
		    	        payload_len = buf->p->len;
		    	        payload_data = buf->p->payload;

		    	        /* Copy the recieved message into the command string */
		    	        signed char cInputString[payload_len];
		    	        strncpy(cInputString, payload_data, payload_len);

	    	        	/* create new buffers and send them for each line of the output */
	    	        	do{
	    	        		/*Pass the string to FreeRTOS+CLI. */
				    	    xMoreDataToFollow = FreeRTOS_CLIProcessCommand( cInputString, cOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );

				    	    /*create a buffer to send the data and fill it with output */
   			    	        buf_send = netbuf_new();
   			    	        data = netbuf_alloc(buf_send, sizeof(cOutputString));
  			    	        memcpy(data, cOutputString, sizeof(cOutputString));
   		    	        	/* Send the output generated by the command's implementation. */
   			    	        netconn_sendto(conn, buf_send, dst_addr, dst_port);
   			    	        if (send_err == 0) { PINS_DRV_TogglePins(PTE, 0x40) ;}// PINS_DRV_TogglePins(PTH, 0x20);} //PE6 and internal PH5

   			    	        /* Free the buffer */
   			    	        netbuf_delete(buf_send);
       					} while( xMoreDataToFollow != pdFALSE ); /* keep sending until the command does not generate any more output. */


		    	        /* Free the buffer */
		    	        netbuf_delete(buf);
		    	        }
    	}
}

The /main.c:

#include "platform.h"
#include "Cpu.h"
#include "FreeRTOS.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "task.h"
#include "stdio.h"
#include "../include/CLIfuncs.h"

extern void vRegisterCLICommands( void );

volatile int exit_code = 0;

int main(void)
{
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of Processor Expert internal initialization.                    ***/
  /* Write your code here */
    /* Initialize and configure clocks */
        CLOCK_SYS_Init(g_clockManConfigsArr, (uint8_t)CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, (uint8_t)CLOCK_MANAGER_CALLBACK_CNT);
        CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

        /* Initialize pins */
        PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

        /* create Tasks */
        xTaskCreate(vUDPCommandConsoleTask, "UDPCommandConsoleTask", 256U, NULL, 9, NULL);
        xTaskCreate(vBlinkLEDTask, "blinkLEDTask", 256U, NULL, 1, NULL);
        vRegisterCLICommands();
    	vTaskStartScheduler();
  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}

You don’t need to register the help command - that is done for you. Can you put a break point in the code that recognises the end of the command by either the carriage return or newline character, then type in “help” and press enter to hit the break point - then step through the code from there in the debugger to see why it is not recognised.

thanks for the reply.
I figured out where the problem is - need to invoke 'help ', with a spacebar on the last postion to get the function running.

Why is that? The string does not have a space at the end: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c#L70

I don’t understand it either.
Maybe it is an issue of a telnet client I am using?