What should I put the value of vPlatformInitLogging() command?

I have written the following code for my microcontroller for deploying an HTTP server:

#include "McuRTOS.h"
#include "FreeRTOS_IP.h"

#include "logging.h"
#include "demo_config.h"

#include "artya7.h"

const uint8_t IPADDRESS[4]   = {192, 168, 0, 17};
const uint8_t MASK[4]         = {255, 255, 255, 0};
const uint8_t GATEWAY[4]      = {192, 168, 0, 1};
const uint8_t DNS[4]          = {192, 168, 0, 1};

const uint8_t MAC[6]          = {0x00, 0x00, 0x5E, 0x00, 0xFA, 0xCE};


extern void vStartSimpleHTTPDemo(void);

extern void vPlatformInitIpStack(void);


int main(void)
{
    BaseType_t state;

    vPlatformInitLogging(); // Initialize logging


    // Initialize the FreeRTOS+TCP Stack
    vPlatformInitIpStack();


    state = xTaskGetSchedulerState();

    if(state == taskSCHEDULER_NOT_STARTED)
    {
        vTaskStartScheduler();
    }

    while(1);

    return 0;
}

void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
{
    if(eNetworkEvent == eNetworkUp)
    {
        ARTYA7_LEDx(2, 1);

        vStartSimpleHTTPDemo();

        vTaskStartScheduler();
    }
    else if(eNetworkEvent == eNetworkDown)
    {

    }
}

void vPlatformInitIpStack()
{
    BaseType_t ipState;

    ipState = FreeRTOS_IPInit(IPADDRESS, MASK, GATEWAY, DNS, MAC);

    // Check if IP stack initialization was successful
    if(ipState != pdPASS)
    {
        // Handle initialization failure
        // For example, log an error message or take appropriate action
    }
}

void vPlatformInitLogging()
{
    // Initialize logging with the configured parameters
//    vLoggingInit(xLogToStdout, xLogToFile, xLogToUDP, ulRemoteIPAddress, usRemotePort);
	unsigned int test  = 0;


}

void vLoggingPrintf(const char *logError, ...)
{

	logError = "me";

}

The problem is that the Logging Command is giving out several errors at the point of initialization and beyond that. Will someone please guide me on why the following error messages may be appearing in this code?

The console shows the error messages undefined reference to uxRand. What should I define the value of uxRand()?

Can you please provide more information on the microcontroller you are attempting to run your HTTP server on? Without your board and specific error message it will be quite difficult to provide a useful answer.

The vPlatformInitLogging function is used in several of our Plus demos with the vLoggingInit used for the windows simulator. A more appropriate logging method is likely available for your MCU.

What errors do you see?

You likely want to implement this using a Random Number Generator (RNG) available on your hardware.

I am using the ARM Cortex M0+ microcontroller board. The error messages are as follows:

c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:335: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:335: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:338: undefined reference to `xPlatformIsNetworkUp'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:340: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:340: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:340: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:342: undefined reference to `xPlatformIsNetworkUp'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:372: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:372: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:372: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:412: undefined reference to `vLoggingPrintf'
c:/users/user/appdata/roaming/xpacks/@xpack-dev-tools/arm-none-eabi-gcc/12.3.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: E:\embedded\embedded\NUBLX_SYS_1002\work\NUBLX_SYS_1002_FreeRTOS_TCP_Project\Debug/../FreeRTOS_http/src/PlainTextHTTPExample.c:412: undefined reference to `vLoggingPrintf'

Can you also throw some pointers on how to use the VLoggingPrintF command in this code appropriately. I didn’t find any material related to this command on the forums or the FreeRTOS website.

This is a vLoggingPrintf implementation for Windows - FreeRTOS/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c at main · FreeRTOS/FreeRTOS · GitHub. You can refer this to write one for you platform.

in function vStartSimpleHTTPDemo( void ) which is called in main program when my network is up , so in this function a task is created by name prvHTTPDemoTask in which

   do
    {
        LogInfo( ( "---------STARTING DEMO---------\r\n" ) );

        /* Wait for Networking */
        if( xPlatformIsNetworkUp() == pdFALSE )
        {
            LogInfo( ( "Waiting for the network link up event..." ) );

            while( xPlatformIsNetworkUp() == pdFALSE )
            {
                vTaskDelay( pdMS_TO_TICKS( 1000U ) );
            }
        }

error occur in LogInfo( ( “---------STARTING DEMO---------\r\n” ) );
and give me several errors but when i wrote

  LogInfo( ( message ) );  

so this gave out only two errors. I can’t understand the logic behind it. how can I fix this issue because the console is unavailabe in my Eclipse IDE.

I have copy the .c file from your reference pointer okay . FreeRTOS/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c at main · FreeRTOS/FreeRTOS · GitHub ,
so I have face the error
in “HANDLE”
HANDLE xCurrentTask;
error “Type ‘HANDLE’ could not be resolved”

so how to resolve this

As I mentioned, this file is for Windows and you’ll need to write one for your platform. What are you trying to achieve? Do you just want to enable logging for your platform? If yes, can you share your complete code?

basicallly im writing a code for connection HTTP server connection using freeRTOS and i downlaod all file about corehttp but i just adjust all files in my system… and now here is error in Handle and dont know how to resolve this kindly confirm me how i can solve this issue or guide me how i can connect http server using freertos or tell me also roadmap what should i do first in rigth way? I’m waiting for your response… but don’t forget this issue “Handle”.

and in my windows file this file isn’t mention

LogInfo is a macro - the easiest is to choose a log level (likely LOG_NONE) which removes all the logs. This will ensure that you only have logging issue and nothing else.

Do not compile this file. In other words, delete it.

void vLoggingPrintf( const char * pcFormat,
                     ... )
{
    char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
    char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
    char * pcSource, * pcTarget, * pcBegin;
    size_t xLength, xLength2, rc;
    static BaseType_t xMessageNumber = 0;
    static BaseType_t xAfterLineBreak = pdTRUE;
    va_list args;
    uint32_t ulIPAddress;
    const char * pcTaskName;
    const char * pcNoTask = "None";
    int iOriginalPriority;
//    HANDLE xCurrentTask;


    if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
    {
        /* There are a variable number of parameters. */
        va_start( args, pcFormat );

        /* Additional info to place at the start of the log. */
        if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
        {
            pcTaskName = pcTaskGetName( NULL );
        }
        else
        {
            pcTaskName = pcNoTask;
        }

        if( ( xAfterLineBreak == pdTRUE ) && ( strcmp( pcFormat, "\r\n" ) != 0 ) )
        {
            xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
                                xMessageNumber++,
                                ( unsigned long ) xTaskGetTickCount(),
                                pcTaskName );
            xAfterLineBreak = pdFALSE;
        }
        else
        {
            xLength = 0;
            memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
            xAfterLineBreak = pdTRUE;
        }

        xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );

        if( xLength2 < 0 )
        {
            /* Clean up. */
            xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
            cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
        }

        xLength += xLength2;
        va_end( args );

        /* For ease of viewing, copy the string into another buffer, converting
         * IP addresses to dot notation on the way. */
        pcSource = cPrintString;
        pcTarget = cOutputString;

        while( ( *pcSource ) != '\0' )
        {
            *pcTarget = *pcSource;
            pcTarget++;
            pcSource++;

            /* Look forward for an IP address denoted by 'ip'. */
            if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
            {
                *pcTarget = *pcSource;
                pcTarget++;
                *pcTarget = '\0';
                pcBegin = pcTarget - 8;

                while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
                {
                    pcTarget--;
                }

                sscanf( pcTarget, "%8X", &ulIPAddress );
                rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
                              ( unsigned long ) ( ulIPAddress >> 24UL ),
                              ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
                              ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
                              ( unsigned long ) ( ulIPAddress & 0xffUL ) );
                pcTarget += rc;
                pcSource += 3; /* skip "<n>ip" */
            }
        }
        TaskFunction_t xFunctionToPend;


        TickType_t xTicksToWait;
        const struct freertos_sockaddr *pxDestinationAddress;
        socklen_t xDestinationAddressLength;

        /* How far through the buffer was written? */
        xLength = ( BaseType_t ) ( pcTarget - cOutputString );

        /* If the message is to be logged to a UDP port then it can be sent directly
         * because it only uses FreeRTOS function (not Win32 functions). */
        if( xUDPLoggingUsed != pdFALSE )
        {
            if( ( xPrintSocket == FREERTOS_INVALID_SOCKET() ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
            {
                /* Create and bind the socket to which print messages are sent.  The
                 * xTimerPendFunctionCall() function is used even though this is
                 * not an interrupt because this function is called from the IP task
                 * and the	IP task cannot itself wait for a socket to bind.  The
                 * parameters to prvCreatePrintSocket() are not required so set to
                 * NULL or 0. */
                xTimerPendFunctionCall( xFunctionToPend, NULL, 0, xTicksToWait );
            }

            if( xPrintSocket() != FREERTOS_INVALID_SOCKET() )
            {
                FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &pxDestinationAddress, sizeof( xDestinationAddressLength ) );

                /* Just because the UDP data logger I'm using is dumb. */
                FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &pxDestinationAddress, sizeof( xDestinationAddressLength ) );
            }
        }

        /* If logging is also to go to either stdout or a disk file then it cannot
         * be output here - so instead write the message to the stream buffer and wake
         * the Win32 thread which will read it from the stream buffer and perform the
         * actual output. */
        if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
        {
            configASSERT( xLogStreamBuffer );

            /* How much space is in the buffer? */
            xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );

            /* There must be enough space to write both the string and the length of
             * the string. */
            if( xLength2 >= ( xLength + sizeof( xLength ) ) )
            {
                /* First write in the length of the data, then write in the data
                 * itself.  Raising the thread priority is used as a critical section
                 * as there are potentially multiple writers.  The stream buffer is
                 * only thread safe when there is a single writer (likewise for
                 * reading from the buffer). */
//                xCurrentTask = GetCurrentThread();
//                iOriginalPriority = GetThreadPriority( xCurrentTask );
//                SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
                uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
                uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
                SetThreadPriority( GetCurrentThread(), iOriginalPriority );
            }

            /* xDirectPrint is initialized to pdTRUE, and while it remains true the
             * logging output function is called directly.  When the system is running
             * the output function cannot be called directly because it would get
             * called from both FreeRTOS tasks and Win32 threads - so instead wake the
             * Win32 thread responsible for the actual output. */

            BaseType_t xDirectPrint;
            BaseType_t pvLoggingThreadEvent;

            if( xDirectPrint != pdFALSE )
            {
                /* While starting up, the thread which calls prvWin32LoggingThread()
                 * is not running yet and xDirectPrint will be pdTRUE. */
                prvLoggingFlushBuffer();
            }
            else if( pvLoggingThreadEvent != NULL )
            {
                /* While running, wake up prvWin32LoggingThread() to send the
                 * logging data. */
                SetEvent( pvLoggingThreadEvent );
            }
        }
    }
}

this is the errors i face

../FreeRTOS_http/src/logging.c:210:19: error: 'xPrintSocket' undeclared (first use in this function)
  210 |             if( ( xPrintSocket == FREERTOS_INVALID_SOCKET() ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
      |                   ^~~~~~~~~~~~
../FreeRTOS_http/src/logging.c:210:19: note: each undeclared identifier is reported only once for each function it appears in
../FreeRTOS_http/src/logging.c:210:35: warning: implicit declaration of function 'FREERTOS_INVALID_SOCKET' [-Wimplicit-function-declaration]
  210 |             if( ( xPrintSocket == FREERTOS_INVALID_SOCKET() ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS_http/src/logging.c:218:17: warning: implicit declaration of function 'xTimerPendFunctionCall'; did you mean 'INCLUDE_xTimerPendFunctionCall'? [-Wimplicit-function-declaration]
  218 |                 xTimerPendFunctionCall( xFunctionToPend, NULL, 0, xTicksToWait );
      |                 ^~~~~~~~~~~~~~~~~~~~~~
      |                 INCLUDE_xTimerPendFunctionCall
../FreeRTOS_http/src/logging.c:221:17: warning: implicit declaration of function 'xPrintSocket' [-Wimplicit-function-declaration]
  221 |             if( xPrintSocket() != FREERTOS_INVALID_SOCKET() )
      |                 ^~~~~~~~~~~~
../FreeRTOS_http/src/logging.c:223:17: warning: implicit declaration of function 'FreeRTOS_sendto'; did you mean 'FreeRTOS_IPInit'? [-Wimplicit-function-declaration]
  223 |                 FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &pxDestinationAddress, sizeof( xDestinationAddressLength ) );
      |                 ^~~~~~~~~~~~~~~
      |                 FreeRTOS_IPInit
../FreeRTOS_http/src/logging.c:239:24: warning: implicit declaration of function 'uxStreamBufferGetSpace' [-Wimplicit-function-declaration]
  239 |             xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
      |          
              ^~~~~~~~~~~~~~~~~~~~~~

please brief me where can I declare the ‘xPrintSocket’ and how to declare it and brief me about the other erros
Thankyou

Did you try disabling logs as I suggested above?

so how i can disable logs??

Can you share your code?

which one code ?
I have already send you logging.C file above if you concern about the main program so I can send you?

If you need another file so please mention I can give you ASAP.

Can you share the complete code? May be put it in GitHub and share link?

share your email address if it is possible I can send you zip file? beacuse GitHub link unavailable at that time

and this is the main program

#include "McuRTOS.h"
#include "FreeRTOS_IP.h"

#include "logging.h"
#include "demo_config.h"
#include "transport_interface.h"

#include "artya7.h"

const uint8_t IPADDRESS[4]   = {192, 168, 0, 17};
const uint8_t MASK[4]         = {255, 255, 255, 0};
const uint8_t GATEWAY[4]      = {192, 168, 0, 1};
const uint8_t DNS[4]          = {192, 168, 0, 1};

const uint8_t MAC[6]          = {0x00, 0x00, 0x5E, 0x00, 0xFA, 0xCE};



extern void vStartSimpleHTTPDemo(void);

extern void vPlatformInitIpStack(void);


int main(void)
{
    BaseType_t state;

    vPlatformInitLogging(); // Initialize logging


    // Initialize the FreeRTOS+TCP Stack
    vPlatformInitIpStack();


    state = xTaskGetSchedulerState();

    if(state == taskSCHEDULER_NOT_STARTED)
    {
        vTaskStartScheduler();
    }

    while(1);

    return 0;
}

void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
{
    if(eNetworkEvent == eNetworkUp)
    {
        ARTYA7_LEDx(2, 1);

        vStartSimpleHTTPDemo();

        vTaskStartScheduler();
    }
    else if(eNetworkEvent == eNetworkDown)
    {

    }
}

void vPlatformInitIpStack()
{
    BaseType_t ipState;

    ipState = FreeRTOS_IPInit(IPADDRESS, MASK, GATEWAY, DNS, MAC);

    // Check if IP stack initialization was successful
    if(ipState != pdPASS)
    {
        // Handle initialization failure
        // For example, log an error message or take appropriate action
    }
}


void vPlatformInitLogging( void )
{
	vLoggingInit( pdTRUE, pdFALSE, pdFALSE, 0U, 0U );

	BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;

}