diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c
index 10b30c8672..13989c8d8b 100644
--- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c
+++ b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c
@@ -46,7 +46,7 @@
#include "FreeRTOS_Sockets.h"
/* Demo logging includes. */
-#include "demo_logging.h"
+#include "logging.h"
/* Demo Specific configs. */
#include "demo_config.h"
diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj
index 436658602b..05e4dc19f8 100644
--- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\Common\Logging;..\common\WinPCap;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\platform\include;..\..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\..\Source\mbedtls_utils;..\..\..\..\ThirdParty\mbedtls\include;..\..\..\..\Source\AWS\device-shadow-for-aws-iot-embedded-sdk\source\include;..\..\..\..\Source\coreJSON\source\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\..\FreeRTOS-Plus\Source\Logging;..\common\WinPCap;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\platform\include;..\..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\..\Source\mbedtls_utils;..\..\..\..\ThirdParty\mbedtls\include;..\..\..\..\Source\AWS\device-shadow-for-aws-iot-embedded-sdk\source\include;..\..\..\..\Source\coreJSON\source\include;.;%(AdditionalIncludeDirectories)
MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -487,7 +487,7 @@
TurnOffAllWarnings
TurnOffAllWarnings
-
+
@@ -516,6 +516,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj.filters
index 45dbbffb18..3263f38b13 100644
--- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/WIN32.vcxproj.filters
@@ -139,7 +139,7 @@
FreeRTOS\Source
-
+
FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT\src
@@ -165,85 +165,243 @@
FreeRTOS+\FreeRTOS IoT Libraries\platform\freertos\transport\src
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
+
+ FreeRTOS+\mbedtls\library
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj
index 4fafe8f503..73a5ad5692 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj
@@ -116,7 +116,7 @@
.\Release/
Level3
true
- ..\Common\Utils;..\Common\ethernet\lwip-1.4.0\ports\win32\WinPCap;..\Common\ethernet\lwip-1.4.0\src\include\ipv4;..\Common\ethernet\lwip-1.4.0\src\include;..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\ethernet\lwip-1.4.0\ports\win32\include;..\Common\Include;.\lwIP_Apps;.;%(AdditionalIncludeDirectories)
+ ..\Common\Utils;..\Common\ethernet\lwip-1.4.0\ports\win32\WinPCap;..\Common\ethernet\lwip-1.4.0\src\include\ipv4;..\Common\ethernet\lwip-1.4.0\src\include;..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\ethernet\lwip-1.4.0\ports\win32\include;..\Common\Include;..\..\Source\Logging;.\lwIP_Apps;.;%(AdditionalIncludeDirectories)
NDEBUG;%(PreprocessorDefinitions)
@@ -155,10 +155,10 @@
+
-
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj.filters
index de00fc84ab..eaf833ad80 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/WIN32.vcxproj.filters
@@ -96,7 +96,7 @@
FreeRTOS+\FreeRTOS+TCP
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.c
deleted file mode 100644
index ec4687a866..0000000000
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-/*
- * Logging utility that allows FreeRTOS tasks to log to a UDP port, stdout, and
- * disk file without making any Win32 system calls themselves.
- *
- * Messages logged to a UDP port are sent directly (using FreeRTOS+TCP), but as
- * FreeRTOS tasks cannot make Win32 system calls messages sent to stdout or a
- * disk file are sent via a stream buffer to a Win32 thread which then performs
- * the actual output.
- */
-
-/* Standard includes. */
-#include
-#include
-#include
-#include
-#include
-
-/* FreeRTOS includes. */
-#include
-#include "task.h"
-
-/* FreeRTOS+TCP includes. */
-#include "FreeRTOS_IP.h"
-#include "FreeRTOS_Sockets.h"
-#include "FreeRTOS_Stream_Buffer.h"
-
-/* Demo includes. */
-#include "demo_logging.h"
-
-/*-----------------------------------------------------------*/
-
-/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
-
-/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
-
-/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
-
-/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
-
-/*-----------------------------------------------------------*/
-
-/*
- * Called from vLoggingInit() to start a new disk log file.
- */
-static void prvFileLoggingInit( void );
-
-/*
- * Attempt to write a message to the file.
- */
-static void prvLogToFile( const char *pcMessage, size_t xLength );
-
-/*
- * Simply close the logging file, if it is open.
- */
-static void prvFileClose( void );
-
-/*
- * Before the scheduler is started this function is called directly. After the
- * scheduler has started it is called from the Windows thread dedicated to
- * outputting log messages. Only the windows thread actually performs the
- * writing so as not to disrupt the simulation by making Windows system calls
- * from FreeRTOS tasks.
- */
-static void prvLoggingFlushBuffer( void );
-
-/*
- * The windows thread that performs the actual writing of messages that require
- * Win32 system calls. Only the windows thread can make system calls so as not
- * to disrupt the simulation by making Windows calls from FreeRTOS tasks.
- */
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
-
-/*
- * Creates the socket to which UDP messages are sent. This function is not
- * called directly to prevent the print socket being created from within the IP
- * task - which could result in a deadlock. Instead the function call is
- * deferred to run in the RTOS daemon task - hence it prototype.
- */
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
-
-/*-----------------------------------------------------------*/
-
-/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
-
-/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
-
-/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
-
-/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
-
-/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
-
-/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
-
-/* Keep the current file size in a variable, as an optimisation. */
-static size_t ulSizeOfLoggingFile = 0ul;
-
-/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
-struct freertos_sockaddr xPrintUDPAddress;
-
-/*-----------------------------------------------------------*/
-
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
-{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialise it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialised. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
-}
-/*-----------------------------------------------------------*/
-
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
-{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
-
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
-
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
-
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
-
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
-}
-/*-----------------------------------------------------------*/
-
-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;
-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( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- 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 "ip" */
- }
- }
-
- /* 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( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* 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 initialised 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. */
- 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 );
- }
- }
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLoggingFlushBuffer( void )
-{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- printf( "%s", cPrintString ); /*_RB_ Replace with _write(). */
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
-}
-/*-----------------------------------------------------------*/
-
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
-{
-const DWORD xMaxWait = 1000;
-
- ( void ) pvParameter;
-
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
-
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
-
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileLoggingInit( void )
-{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileClose( void )
-{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLogToFile( const char *pcMessage, size_t xLength )
-{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
-}
-/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.h
deleted file mode 100644
index 8aa3ecf962..0000000000
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/demo_logging.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef DEMO_LOGGING_H
-#define DEMO_LOGGING_H
-
-/*
- * Initialise a logging system that can be used from FreeRTOS tasks and Win32
- * threads. Do not call printf() directly while the scheduler is running.
- *
- * Set xLogToStdout, xLogToFile and xLogToUDP to either pdTRUE or pdFALSE to
- * lot to stdout, a disk file and a UDP port respectively.
- *
- * If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
- * to the IP address and port number to which UDP log messages will be sent.
- */
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
-
-#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c
index b91ebf32d9..6a2203c206 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c
@@ -46,50 +46,50 @@
#include "SimpleUDPClientAndServer.h"
#include "SimpleTCPEchoServer.h"
#include "TCPEchoClient_SingleTasks.h"
-#include "demo_logging.h"
+#include "logging.h"
/* Simple UDP client and server task parameters. */
-#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
-#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
+#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
+#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
/* Echo client task parameters - used for both TCP and UDP echo clients. */
-#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
-#define mainECHO_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
+#define mainECHO_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* Echo server task parameters. */
-#define mainECHO_SERVER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
-#define mainECHO_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#define mainECHO_SERVER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
+#define mainECHO_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* Define a name that will be used for LLMNR and NBNS searches. */
-#define mainHOST_NAME "RTOSDemo"
-#define mainDEVICE_NICK_NAME "windows_demo"
+#define mainHOST_NAME "RTOSDemo"
+#define mainDEVICE_NICK_NAME "windows_demo"
/* Set the following constants to 1 or 0 to define which tasks to include and
-exclude:
-
-mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS: When set to 1 two UDP client tasks
-and two UDP server tasks are created. The clients talk to the servers. One set
-of tasks use the standard sockets interface, and the other the zero copy sockets
-interface. These tasks are self checking and will trigger a configASSERT() if
-they detect a difference in the data that is received from that which was sent.
-As these tasks use UDP, and can therefore loose packets, they will cause
-configASSERT() to be called when they are run in a less than perfect networking
-environment.
-
-mainCREATE_TCP_ECHO_TASKS_SINGLE: When set to 1 a set of tasks are created that
-send TCP echo requests to the standard echo port (port 7), then wait for and
-verify the echo reply, from within the same task (Tx and Rx are performed in the
-same RTOS task). The IP address of the echo server must be configured using the
-configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
-FreeRTOSConfig.h.
-
-mainCREATE_TCP_ECHO_SERVER_TASK: When set to 1 a task is created that accepts
-connections on the standard echo port (port 7), then echos back any data
-received on that connection.
-*/
-#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1
-#define mainCREATE_TCP_ECHO_TASKS_SINGLE 0
-#define mainCREATE_TCP_ECHO_SERVER_TASK 0
+ * exclude:
+ *
+ * mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS: When set to 1 two UDP client tasks
+ * and two UDP server tasks are created. The clients talk to the servers. One set
+ * of tasks use the standard sockets interface, and the other the zero copy sockets
+ * interface. These tasks are self checking and will trigger a configASSERT() if
+ * they detect a difference in the data that is received from that which was sent.
+ * As these tasks use UDP, and can therefore loose packets, they will cause
+ * configASSERT() to be called when they are run in a less than perfect networking
+ * environment.
+ *
+ * mainCREATE_TCP_ECHO_TASKS_SINGLE: When set to 1 a set of tasks are created that
+ * send TCP echo requests to the standard echo port (port 7), then wait for and
+ * verify the echo reply, from within the same task (Tx and Rx are performed in the
+ * same RTOS task). The IP address of the echo server must be configured using the
+ * configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
+ * FreeRTOSConfig.h.
+ *
+ * mainCREATE_TCP_ECHO_SERVER_TASK: When set to 1 a task is created that accepts
+ * connections on the standard echo port (port 7), then echos back any data
+ * received on that connection.
+ */
+#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1
+#define mainCREATE_TCP_ECHO_TASKS_SINGLE 0
+#define mainCREATE_TCP_ECHO_SERVER_TASK 0
/*-----------------------------------------------------------*/
/*
@@ -104,28 +104,28 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
@@ -135,222 +135,223 @@ static UBaseType_t ulNextRand;
int main( void )
{
-const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL );
-
- /*
- * Instructions for using this project are provided on:
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
- */
-
- /* Miscellaneous initialisation including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialise the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the definition of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- FreeRTOS_debug_printf( ("vTaskStartScheduler\n") );
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not not
- really applicable to the Win32 simulator port). */
- for( ;; )
- {
- Sleep( ulLongTime_ms );
- }
+ const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL );
+
+ /*
+ * Instructions for using this project are provided on:
+ * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
+ */
+
+ /* Miscellaneous initialisation including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialise the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the definition of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ Sleep( ulLongTime_ms );
+ }
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
-const uint32_t ulMSToSleep = 1;
+ const uint32_t ulMSToSleep = 1;
- /* This is just a trivial example of an idle hook. It is called on each
- cycle of the idle task if configUSE_IDLE_HOOK is set to 1 in
- FreeRTOSConfig.h. It must *NOT* attempt to block. In this case the
- idle task just sleeps to lower the CPU usage. */
- Sleep( ulMSToSleep );
+ /* This is just a trivial example of an idle hook. It is called on each
+ * cycle of the idle task if configUSE_IDLE_HOOK is set to 1 in
+ * FreeRTOSConfig.h. It must *NOT* attempt to block. In this case the
+ * idle task just sleeps to lower the CPU usage. */
+ Sleep( ulMSToSleep );
}
/*-----------------------------------------------------------*/
-void vAssertCalled( const char *pcFile, uint32_t ulLine )
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
-const uint32_t ulLongSleep = 1000UL;
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char *pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- FreeRTOS_debug_printf( ( "vAssertCalled( %s, %ld\n", pcFile, ulLine ) );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- Sleep( ulLongSleep );
- }
- }
- taskENABLE_INTERRUPTS();
+ const uint32_t ulLongSleep = 1000UL;
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ FreeRTOS_debug_printf( ( "vAssertCalled( %s, %ld\n", pcFile, ulLine ) );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ Sleep( ulLongSleep );
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* See the comments above the definitions of these pre-processor
- macros at the top of this file for a description of the individual
- demo tasks. */
- #if( mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS == 1 )
- {
- vStartSimpleUDPClientServerTasks( configMINIMAL_STACK_SIZE, mainSIMPLE_UDP_CLIENT_SERVER_PORT, mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY );
- }
- #endif /* mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS */
-
- #if( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )
- {
- vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );
- }
- #endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */
-
- #if( mainCREATE_TCP_ECHO_SERVER_TASK == 1 )
- {
- vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY );
- }
- #endif
-
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* See the comments above the definitions of these pre-processor
+ * macros at the top of this file for a description of the individual
+ * demo tasks. */
+ #if ( mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS == 1 )
+ {
+ vStartSimpleUDPClientServerTasks( configMINIMAL_STACK_SIZE, mainSIMPLE_UDP_CLIENT_SERVER_PORT, mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY );
+ }
+ #endif /* mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS */
+
+ #if ( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )
+ {
+ vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );
+ }
+ #endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */
+
+ #if ( mainCREATE_TCP_ECHO_SERVER_TASK == 1 )
+ {
+ vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY );
+ }
+ #endif
+
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
void vApplicationMallocFailedHook( void )
{
- /* Called if a call to pvPortMalloc() fails because there is insufficient
- free memory available in the FreeRTOS heap. pvPortMalloc() is called
- internally by FreeRTOS API functions that create tasks, queues, software
- timers, and semaphores. The size of the FreeRTOS heap is set by the
- configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
- vAssertCalled( __FILE__, __LINE__ );
+ /* Called if a call to pvPortMalloc() fails because there is insufficient
+ * free memory available in the FreeRTOS heap. pvPortMalloc() is called
+ * internally by FreeRTOS API functions that create tasks, queues, software
+ * timers, and semaphores. The size of the FreeRTOS heap is set by the
+ * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
+ vAssertCalled( __FILE__, __LINE__ );
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
- /* Utility function to generate a pseudo random number. */
+ /* Utility function to generate a pseudo random number. */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
- /* Seed the random number generator. */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ /* Seed the random number generator. */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
-#if( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
+#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char *pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
-#if( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
-
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
-
-#endif
+#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
+
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
+
+#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*
* Callback that provides the inputs necessary to generate a randomized TCP
@@ -359,26 +360,25 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*
- * Supply a random number to FreeRTOS+TCP stack.
- * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER
+ * Supply a random number to FreeRTOS+TCP stack.
+ * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER
* SO IS NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
-BaseType_t xApplicationGetRandomNumber(uint32_t* pulNumber)
+BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *(pulNumber) = uxRand();
- return pdTRUE;
+ *( pulNumber ) = uxRand();
+ return pdTRUE;
}
-
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.c
deleted file mode 100644
index cd2cf8dfbe..0000000000
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * FreeRTOS Kernel V10.3.0
- * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-/*
- * Logging utility that allows FreeRTOS tasks to log to a UDP port, stdout, and
- * disk file without making any Win32 system calls themselves.
- *
- * Messages logged to a UDP port are sent directly (using FreeRTOS+TCP), but as
- * FreeRTOS tasks cannot make Win32 system calls messages sent to stdout or a
- * disk file are sent via a stream buffer to a Win32 thread which then performs
- * the actual output.
- */
-
-/* Standard includes. */
-#include
-#include
-#include
-#include
-#include
-
-/* FreeRTOS includes. */
-#include
-#include "task.h"
-
-/* FreeRTOS+TCP includes. */
-#include "FreeRTOS_IP.h"
-#include "FreeRTOS_Sockets.h"
-#include "FreeRTOS_Stream_Buffer.h"
-
-/* Demo includes. */
-#include "demo_logging.h"
-
-/*-----------------------------------------------------------*/
-
-/* The maximum size to which the log file may grow, before being renamed
- * to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
-
-/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
-
-/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
- * the Win32 thread that is responsible for making any Win32 system calls that are
- * necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
-
-/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
-
-/*-----------------------------------------------------------*/
-
-/*
- * Called from vLoggingInit() to start a new disk log file.
- */
-static void prvFileLoggingInit( void );
-
-/*
- * Attempt to write a message to the file.
- */
-static void prvLogToFile( const char * pcMessage,
- size_t xLength );
-
-/*
- * Simply close the logging file, if it is open.
- */
-static void prvFileClose( void );
-
-/*
- * Before the scheduler is started this function is called directly. After the
- * scheduler has started it is called from the Windows thread dedicated to
- * outputting log messages. Only the windows thread actually performs the
- * writing so as not to disrupt the simulation by making Windows system calls
- * from FreeRTOS tasks.
- */
-static void prvLoggingFlushBuffer( void );
-
-/*
- * The windows thread that performs the actual writing of messages that require
- * Win32 system calls. Only the windows thread can make system calls so as not
- * to disrupt the simulation by making Windows calls from FreeRTOS tasks.
- */
-static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
-
-/*
- * Creates the socket to which UDP messages are sent. This function is not
- * called directly to prevent the print socket being created from within the IP
- * task - which could result in a deadlock. Instead the function call is
- * deferred to run in the RTOS daemon task - hence it prototype.
- */
-static void prvCreatePrintSocket( void * pvParameter1,
- uint32_t ulParameter2 );
-
-/*-----------------------------------------------------------*/
-
-/* Windows event used to wake the Win32 thread which performs any logging that
- * needs Win32 system calls. */
-static void * pvLoggingThreadEvent = NULL;
-
-/* Stores the selected logging targets passed in as parameters to the
- * vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
-
-/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
- * thread that is responsible for making Win32 calls (when stdout or a disk log is
- * used). */
-static StreamBuffer_t * xLogStreamBuffer = NULL;
-
-/* Handle to the file used for logging. This is left open while there are
- * messages waiting to be logged, then closed again in between logs. */
-static FILE * pxLoggingFileHandle = NULL;
-
-/* When true prints are performed directly. After start up xDirectPrint is set
- * to pdFALSE - at which time prints that require Win32 system calls are done by
- * the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
-
-/* File names for the in use and complete (full) log files. */
-static const char * pcLogFileName = "RTOSDemo.log";
-static const char * pcFullLogFileName = "RTOSDemo.ful";
-
-/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
-
-/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
-struct freertos_sockaddr xPrintUDPAddress;
-
-/*-----------------------------------------------------------*/
-
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort )
-{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- * will be sent - but don't create the socket yet because the network is
- * not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- * have to be made. Such system calls cannot be made from FreeRTOS tasks
- * so create a stream buffer to pass the messages to a Win32 thread, then
- * create the thread itself, along with a Win32 event that can be used to
- * unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- * Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
-}
-/*-----------------------------------------------------------*/
-
-static void prvCreatePrintSocket( void * pvParameter1,
- uint32_t ulParameter2 )
-{
- static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
- Socket_t xSocket;
-
- /* The function prototype is that of a deferred function, but the parameters
- * are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
-
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
-
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
-
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
-}
-/*-----------------------------------------------------------*/
-
-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;
- 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( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- 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 "ip" */
- }
- }
-
- /* 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( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* 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. */
- 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 );
- }
- }
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLoggingFlushBuffer( void )
-{
- size_t xLength;
- char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- * used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- * vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- * vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
-}
-/*-----------------------------------------------------------*/
-
-static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
-{
- const DWORD xMaxWait = 1000;
-
- ( void ) pvParameter;
-
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- * Windows thread */
- xDirectPrint = pdFALSE;
-
- for( ; ; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
-
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileLoggingInit( void )
-{
- FILE * pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileClose( void )
-{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLogToFile( const char * pcMessage,
- size_t xLength )
-{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- * rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
-
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
-
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
-}
-/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.h b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.h
deleted file mode 100644
index 773cc0d75e..0000000000
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/demo_logging.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * FreeRTOS Kernel V10.3.0
- * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef DEMO_LOGGING_H
-#define DEMO_LOGGING_H
-
-/*
- * Initialize a logging system that can be used from FreeRTOS tasks and Win32
- * threads. Do not call printf() directly while the scheduler is running.
- *
- * Set xLogToStdout, xLogToFile and xLogToUDP to either pdTRUE or pdFALSE to
- * lot to stdout, a disk file and a UDP port respectively.
- *
- * If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
- * to the IP address and port number to which UDP log messages will be sent.
- */
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
-
-#endif /* DEMO_LOGGING_H */
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c
index e3026b1ad9..00ebf95182 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c
@@ -46,7 +46,7 @@
#include "FreeRTOS_Sockets.h"
/* Demo logging includes. */
-#include "demo_logging.h"
+#include "logging.h"
/* Demo Specific configs. */
#include "demo_config.h"
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj
index f5a3a6f6f0..7fdb0f11f6 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -485,7 +485,7 @@
TurnOffAllWarnings
TurnOffAllWarnings
-
+
@@ -513,6 +513,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj.filters
index 00d38f128b..27d10398df 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/WIN32.vcxproj.filters
@@ -373,7 +373,7 @@
FreeRTOS+\mbedtls\library
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj
index 56c2145598..e3f1eaec36 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -163,7 +163,7 @@
-
+
@@ -191,6 +191,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj.filters
index 60d0f1b635..660f372dce 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/WIN32.vcxproj.filters
@@ -106,7 +106,7 @@
FreeRTOS\Source
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj
index 16de03fcb4..c6a1a15ea9 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -486,7 +486,7 @@
TurnOffAllWarnings
TurnOffAllWarnings
-
+
@@ -514,6 +514,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj.filters
index 14cff183dc..e10b765677 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/WIN32.vcxproj.filters
@@ -373,7 +373,7 @@
FreeRTOS+\mbedtls\library
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj
index f1bc9c3db2..b9f2834f2b 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\..\..\Source\mbedtls_utils;..\..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -485,7 +485,7 @@
TurnOffAllWarnings
TurnOffAllWarnings
-
+
@@ -513,6 +513,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj.filters
index 995f0597b5..82be6df18c 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/WIN32.vcxproj.filters
@@ -373,7 +373,7 @@
FreeRTOS+\mbedtls\library
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj
index 68f5db1ca5..0089fe06b5 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\platform\freertos\transport\include;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -163,7 +163,7 @@
-
+
@@ -191,6 +191,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj.filters
index 84bf098ab4..dd80b9bd27 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/WIN32.vcxproj.filters
@@ -106,7 +106,7 @@
FreeRTOS\Source
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj
index 4b02816340..8f7649df92 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\Common\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\coreMQTT\source\include;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\FreeRTOS-Plus\Source\Logging;..\Common\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\Application-Protocols\platform\include;..\..\..\Source\Application-Protocols\coreMQTT\source\include;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -159,7 +159,7 @@
-
+
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj.filters
index 7c9725744e..061f240a7e 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Serializer/WIN32.vcxproj.filters
@@ -106,7 +106,7 @@
FreeRTOS\Source
-
+
DemoTasks
diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj
index 5429d53734..d218f78072 100644
--- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\Common\Logging;..\coreMQTT_Windows_Simulator\Common;..\coreMQTT_Windows_Simulator\common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\Source\corePKCS11\source\include;..\..\Source\corePKCS11\3rdparty\pkcs11;..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\Source\Application-Protocols\platform\include;..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
+ ..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\FreeRTOS-Plus\Source\Logging;..\coreMQTT_Windows_Simulator\Common;..\coreMQTT_Windows_Simulator\common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\Source\corePKCS11\source\include;..\..\Source\corePKCS11\3rdparty\pkcs11;..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\Source\Application-Protocols\platform\include;..\..\Source\Application-Protocols\platform\freertos\transport\include;..\..\Source\Application-Protocols\platform\freertos\mbedtls;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)
MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -164,6 +164,7 @@
+
@@ -255,7 +256,6 @@
-
@@ -283,6 +283,9 @@
+
+
+
diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters
index 2230d7ed04..7ae7508d0e 100644
--- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters
@@ -179,7 +179,7 @@
Transport
-
+
Common
diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c
index 99678cc6c6..3306d972ed 100644
--- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c
+++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c
@@ -49,7 +49,7 @@
#include "demo_config.h"
/* Demo logging includes. */
-#include "demo_logging.h"
+#include "logging.h"
/*
* Prototypes for the demos that can be started from this project. Note the
diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj
index 6dd874eb7c..a3cc2a4647 100644
--- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj
@@ -58,7 +58,7 @@
Disabled
- ..\..\..\FreeRTOS-Plus\Demo\Common\Logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\portable\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\pkcs11;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;%(AdditionalIncludeDirectories)
+ ..\..\..\FreeRTOS-Plus\Source\Logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\portable\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\pkcs11;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h";CONFIG_MEDTLS_USE_AFR_MEMORY;%(PreprocessorDefinitions)
false
EnableFastChecks
@@ -149,6 +149,9 @@
+
+
+
@@ -337,8 +340,6 @@
-
-
diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/demo_logging.c b/FreeRTOS-Plus/Source/Logging/logging.c
similarity index 99%
rename from FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/demo_logging.c
rename to FreeRTOS-Plus/Source/Logging/logging.c
index cd2cf8dfbe..8b91a63f29 100644
--- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/demo_logging.c
+++ b/FreeRTOS-Plus/Source/Logging/logging.c
@@ -52,7 +52,7 @@
#include "FreeRTOS_Stream_Buffer.h"
/* Demo includes. */
-#include "demo_logging.h"
+#include "logging.h"
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/demo_logging.h b/FreeRTOS-Plus/Source/Logging/logging.h
similarity index 100%
rename from FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/demo_logging.h
rename to FreeRTOS-Plus/Source/Logging/logging.h
diff --git a/FreeRTOS-Plus/Demo/Common/Logging/logging_levels.h b/FreeRTOS-Plus/Source/Logging/logging_levels.h
similarity index 100%
rename from FreeRTOS-Plus/Demo/Common/Logging/logging_levels.h
rename to FreeRTOS-Plus/Source/Logging/logging_levels.h
diff --git a/FreeRTOS-Plus/Demo/Common/Logging/logging_stack.h b/FreeRTOS-Plus/Source/Logging/logging_stack.h
similarity index 100%
rename from FreeRTOS-Plus/Demo/Common/Logging/logging_stack.h
rename to FreeRTOS-Plus/Source/Logging/logging_stack.h
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/printf-stdarg.c b/FreeRTOS-Plus/Source/Logging/printf-stdarg.c
similarity index 100%
rename from FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/printf-stdarg.c
rename to FreeRTOS-Plus/Source/Logging/printf-stdarg.c
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.c
deleted file mode 100644
index 317861888f..0000000000
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-/*
- * Logging utility that allows FreeRTOS tasks to log to a UDP port, stdout, and
- * disk file without making any Win32 system calls themselves.
- *
- * Messages logged to a UDP port are sent directly (using FreeRTOS+TCP), but as
- * FreeRTOS tasks cannot make Win32 system calls messages sent to stdout or a
- * disk file are sent via a stream buffer to a Win32 thread which then performs
- * the actual output.
- */
-
-/* Standard includes. */
-#include
-#include
-#include
-#include
-#include
-
-/* FreeRTOS includes. */
-#include
-#include "task.h"
-
-/* FreeRTOS+TCP includes. */
-#include "FreeRTOS_IP.h"
-#include "FreeRTOS_Sockets.h"
-#include "FreeRTOS_Stream_Buffer.h"
-
-/* Demo includes. */
-#include "demo_logging.h"
-
-/*-----------------------------------------------------------*/
-
-/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
-
-/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
-
-/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
-
-/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
-
-/*-----------------------------------------------------------*/
-
-/*
- * Called from vLoggingInit() to start a new disk log file.
- */
-static void prvFileLoggingInit( void );
-
-/*
- * Attempt to write a message to the file.
- */
-static void prvLogToFile( const char *pcMessage, size_t xLength );
-
-/*
- * Simply close the logging file, if it is open.
- */
-static void prvFileClose( void );
-
-/*
- * Before the scheduler is started this function is called directly. After the
- * scheduler has started it is called from the Windows thread dedicated to
- * outputting log messages. Only the windows thread actually performs the
- * writing so as not to disrupt the simulation by making Windows system calls
- * from FreeRTOS tasks.
- */
-static void prvLoggingFlushBuffer( void );
-
-/*
- * The windows thread that performs the actual writing of messages that require
- * Win32 system calls. Only the windows thread can make system calls so as not
- * to disrupt the simulation by making Windows calls from FreeRTOS tasks.
- */
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
-
-/*
- * Creates the socket to which UDP messages are sent. This function is not
- * called directly to prevent the print socket being created from within the IP
- * task - which could result in a deadlock. Instead the function call is
- * deferred to run in the RTOS daemon task - hence it prototype.
- */
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
-
-/*-----------------------------------------------------------*/
-
-/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
-
-/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
-
-/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
-
-/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
-
-/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
-
-/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
-
-/* Keep the current file size in a variable, as an optimisation. */
-static size_t ulSizeOfLoggingFile = 0ul;
-
-/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
-struct freertos_sockaddr xPrintUDPAddress;
-
-/*-----------------------------------------------------------*/
-
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
-{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialise it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialised. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
-}
-/*-----------------------------------------------------------*/
-
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
-{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
-
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
-
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
-
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
-
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
-}
-/*-----------------------------------------------------------*/
-
-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;
-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( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- 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 "ip" */
- }
- }
-
- /* 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( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* 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 initialised 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. */
- 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 );
- }
- }
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLoggingFlushBuffer( void )
-{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- printf( "%s", cPrintString ); /*_RB_ Replace with _write(). */
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
-}
-/*-----------------------------------------------------------*/
-
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
-{
-const DWORD xMaxWait = 1000;
-
- ( void ) pvParameter;
-
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
-
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
-
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileLoggingInit( void )
-{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileClose( void )
-{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLogToFile( const char *pcMessage, size_t xLength )
-{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
-}
-/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.h
deleted file mode 100644
index ababb064e6..0000000000
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/Logging/demo_logging.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef DEMO_LOGGING_H
-#define DEMO_LOGGING_H
-
-/*
- * Initialise a logging system that can be used from FreeRTOS tasks and Win32
- * threads. Do not call printf() directly while the scheduler is running.
- *
- * Set xLogToStdout, xLogToFile and xLogToUDP to either pdTRUE or pdFALSE to
- * lot to stdout, a disk file and a UDP port respectively.
- *
- * If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
- * to the IP address and port number to which UDP log messages will be sent.
- */
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
-
-#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj
index 017b3a34d2..606ea65e4a 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj
@@ -62,7 +62,7 @@
Disabled
- .\Logging;.\Test_Code\Test_Runner;..\..\..\CMock\vendor\unity\src;..\..\..\CMock\vendor\unity\extras\fixture\src;.\Config;..\..\..\CMock\vendor\unity\extras\memory\src;..\..\..\..\Source\FreeRTOS-Plus-FAT\include;..\..\..\..\Source\FreeRTOS-Plus-FAT\portable\common;..\..\..\..\Source\FreeRTOS-Plus-TCP\protocols\include;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\FreeRTOS-Plus-CLI;.\Test_Code\Test_Cases;..\..\..\..\Source\FreeRTOS-Plus-TCP\include;.\DemoTasks\include;.\TraceMacros\Example1;.\WinPCap;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\Logging;.\Test_Code\Test_Runner;..\..\..\CMock\vendor\unity\src;..\..\..\CMock\vendor\unity\extras\fixture\src;.\Config;..\..\..\CMock\vendor\unity\extras\memory\src;..\..\..\..\Source\FreeRTOS-Plus-FAT\include;..\..\..\..\Source\FreeRTOS-Plus-FAT\portable\common;..\..\..\..\Source\FreeRTOS-Plus-TCP\protocols\include;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\FreeRTOS-Plus-CLI;.\Test_Code\Test_Cases;..\..\..\..\Source\FreeRTOS-Plus-TCP\include;.\DemoTasks\include;.\TraceMacros\Example1;.\WinPCap;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;FREERTOS_ENABLE_UNIT_TESTS;%(PreprocessorDefinitions)
true
EnableFastChecks
@@ -162,7 +162,7 @@
-
+
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj.filters b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj.filters
index 57a398e435..318ef1a997 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/WIN32.vcxproj.filters
@@ -116,7 +116,7 @@
Test_Code\Test_Runner
-
+
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/main.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/main.c
index db4e893b34..f2f59ff149 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/main.c
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Networkless/main.c
@@ -1,5 +1,5 @@
/*
-* FreeRTOS
+ * FreeRTOS
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -23,12 +23,12 @@
* http://www.FreeRTOS.org
*/
- /**
- * @file main.c
- * @brief Implements the main function.
- */
+/**
+ * @file main.c
+ * @brief Implements the main function.
+ */
- /* FreeRTOS include. */
+/* FreeRTOS include. */
#include
#include "task.h"
@@ -46,11 +46,11 @@
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_DHCP.h"
-#include "demo_logging.h"
+#include "logging.h"
#include "errhandlingapi.h"
-//#include "iot_system_init.h"
+/*#include "iot_system_init.h" */
-//#include "aws_dev_mode_key_provisioning.h"
+/*#include "aws_dev_mode_key_provisioning.h" */
/* Unity includes. */
#include "unity.h"
@@ -64,8 +64,8 @@
#define TEST_RUNNER_TASK_STACK_SIZE 10000
#define FIRST_EXCEPTION_HANDLER 1
- /* Windows-NT VectoredHandler callback function. */
-static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo);
+/* Windows-NT VectoredHandler callback function. */
+static LONG CALLBACK prvExceptionHandler( _In_ PEXCEPTION_POINTERS ExceptionInfo );
jmp_buf xMark; /* Address for long jump to jump to. */
/*-----------------------------------------------------------*/
@@ -78,7 +78,7 @@ static BaseType_t xTraceRunning = pdTRUE;
* to and from a real network connection on the host PC. See the
* configNETWORK_INTERFACE_TO_USE definition for information on how to configure
* the real network connection to use. */
-const uint8_t ucMACAddress[6] =
+const uint8_t ucMACAddress[ 6 ] =
{
configMAC_ADDR0,
configMAC_ADDR1,
@@ -93,28 +93,28 @@ const uint8_t ucMACAddress[6] =
* 1 but a DHCP server could not be contacted. See the online documentation for
* more information. In both cases the node can be discovered using
* "ping RTOSDemo". */
-static const uint8_t ucIPAddress[4] =
+static const uint8_t ucIPAddress[ 4 ] =
{
configIP_ADDR0,
configIP_ADDR1,
configIP_ADDR2,
configIP_ADDR3
};
-static const uint8_t ucNetMask[4] =
+static const uint8_t ucNetMask[ 4 ] =
{
configNET_MASK0,
configNET_MASK1,
configNET_MASK2,
configNET_MASK3
};
-static const uint8_t ucGatewayAddress[4] =
+static const uint8_t ucGatewayAddress[ 4 ] =
{
configGATEWAY_ADDR0,
configGATEWAY_ADDR1,
configGATEWAY_ADDR2,
configGATEWAY_ADDR3
};
-static const uint8_t ucDNSServerAddress[4] =
+static const uint8_t ucDNSServerAddress[ 4 ] =
{
configDNS_SERVER_ADDR0,
configDNS_SERVER_ADDR1,
@@ -126,10 +126,10 @@ static const uint8_t ucDNSServerAddress[4] =
static UBaseType_t ulNextRand;
/*-----------------------------------------------------------*/
-int main(void)
+int main( void )
{
/* Register the Windows VEH for exceptions. */
- //AddVectoredExceptionHandler(FIRST_EXCEPTION_HANDLER, prvExceptionHandler);
+ /*AddVectoredExceptionHandler(FIRST_EXCEPTION_HANDLER, prvExceptionHandler); */
/* Initialize logging for libraries that depend on it. */
vLoggingInit(
@@ -137,7 +137,7 @@ int main(void)
pdFALSE,
pdFALSE,
0,
- 0);
+ 0 );
/* Initialize the network interface.
*
@@ -146,13 +146,13 @@ int main(void)
* vApplicationIPNetworkEventHook() below). The address values passed in here
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
* but a DHCP server cannot be contacted. */
- FreeRTOS_printf(("FreeRTOS_IPInit\n"));
+ FreeRTOS_printf( ( "FreeRTOS_IPInit\n" ) );
FreeRTOS_IPInit(
ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
- ucMACAddress);
+ ucMACAddress );
vTaskStartScheduler();
@@ -160,18 +160,18 @@ int main(void)
}
/*-----------------------------------------------------------*/
-void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
+void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
/* If the network has just come up...*/
- if ((eNetworkEvent == eNetworkUp) && (xTasksAlreadyCreated == pdFALSE))
+ if( ( eNetworkEvent == eNetworkUp ) && ( xTasksAlreadyCreated == pdFALSE ) )
{
- xTaskCreate(TEST_RUNNER_RunTests_task,
- "TestRunner",
- TEST_RUNNER_TASK_STACK_SIZE,
- NULL,
- tskIDLE_PRIORITY, NULL);
+ xTaskCreate( TEST_RUNNER_RunTests_task,
+ "TestRunner",
+ TEST_RUNNER_TASK_STACK_SIZE,
+ NULL,
+ tskIDLE_PRIORITY, NULL );
xTasksAlreadyCreated = pdTRUE;
}
@@ -179,7 +179,7 @@ void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
/*-----------------------------------------------------------*/
-static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo)
+static LONG CALLBACK prvExceptionHandler( _In_ PEXCEPTION_POINTERS ExceptionInfo )
{
/* If this function is called during a test, the test immediately fails. */
TEST_FAIL();
@@ -193,48 +193,48 @@ static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo)
( ipconfigUSE_NBNS != 0 ) || \
( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) )
-const char* pcApplicationHostnameHook(void)
-{
- /* This function will be called during the DHCP: the machine will be registered
- * with an IP address plus this name. */
- return mainHOST_NAME;
-}
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* This function will be called during the DHCP: the machine will be registered
+ * with an IP address plus this name. */
+ return mainHOST_NAME;
+ }
#endif /* if ( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) ) */
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
-BaseType_t xApplicationDNSQueryHook(const char* pcName)
-{
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- * to this node: that returned by pcApplicationHostnameHook() and that set
- * by mainDEVICE_NICK_NAME. */
- if (_stricmp(pcName, pcApplicationHostnameHook()) == 0)
- {
- xReturn = pdPASS;
- }
- else if (_stricmp(pcName, mainDEVICE_NICK_NAME) == 0)
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
{
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
+ BaseType_t xReturn;
- return xReturn;
-}
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
-void vApplicationIdleHook(void)
+void vApplicationIdleHook( void )
{
const uint32_t ulMSToSleep = 1;
- const TickType_t xKitHitCheckPeriod = pdMS_TO_TICKS(1000UL);
+ const TickType_t xKitHitCheckPeriod = pdMS_TO_TICKS( 1000UL );
static TickType_t xTimeNow, xLastTimeCheck = 0;
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
@@ -247,19 +247,17 @@ void vApplicationIdleHook(void)
* because it is the responsibility of the idle task to clean up memory
* allocated by the kernel to any task that has since deleted itself. */
- /* _kbhit() is a Windows system function, and system functions can cause
- * crashes if they somehow block the FreeRTOS thread. The call to _kbhit()
- * can be removed if it causes problems. Limiting the frequency of calls to
- * _kbhit() should minimize the potential for issues. */
+ /* _kbhit() is a Windows system function, and system functions can cause
+ * crashes if they somehow block the FreeRTOS thread. The call to _kbhit()
+ * can be removed if it causes problems. Limiting the frequency of calls to
+ * _kbhit() should minimize the potential for issues. */
xTimeNow = xTaskGetTickCount();
- if ((xTimeNow - xLastTimeCheck) > xKitHitCheckPeriod)
+ if( ( xTimeNow - xLastTimeCheck ) > xKitHitCheckPeriod )
{
-
-
/* Uncomment the print line to get confirmation that tests are still
* running if you suspect a previous run resulted in a crash. */
- /* configPRINTF( ( "Running...\n" ) ); /**/
+ /* configPRINTF( ( "Running...\n" ) ); /**/
xLastTimeCheck = xTimeNow;
}
@@ -267,53 +265,53 @@ void vApplicationIdleHook(void)
* cycle of the idle task if configUSE_IDLE_HOOK is set to 1 in
* FreeRTOSConfig.h. It must *NOT* attempt to block. In this case the
* idle task just sleeps to lower the CPU usage. */
- Sleep(ulMSToSleep);
+ Sleep( ulMSToSleep );
}
/*-----------------------------------------------------------*/
-void vAssertCalled(const char* pcFile,
- uint32_t ulLine)
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
const uint32_t ulLongSleep = 1000UL;
volatile uint32_t ulBlockVariable = 0UL;
- volatile char* pcFileName = (volatile char*)pcFile;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
volatile uint32_t ulLineNumber = ulLine;
- (void)pcFileName;
- (void)ulLineNumber;
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
- printf("vAssertCalled %s, %ld\n", pcFile, (long)ulLine);
- fflush(stdout);
+ printf( "vAssertCalled %s, %ld\n", pcFile, ( long ) ulLine );
+ fflush( stdout );
/* Setting ulBlockVariable to a non-zero value in the debugger will allow
* this function to be exited. */
taskDISABLE_INTERRUPTS();
{
- while (ulBlockVariable == 0UL)
+ while( ulBlockVariable == 0UL )
{
- Sleep(ulLongSleep);
+ Sleep( ulLongSleep );
}
}
taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
-void getUserCmd(char* pucUserCmd)
+void getUserCmd( char * pucUserCmd )
{
char cTmp;
- scanf("%c%c", pucUserCmd, &cTmp);
+ scanf( "%c%c", pucUserCmd, &cTmp );
}
/*-----------------------------------------------------------*/
-UBaseType_t uxRand(void)
+UBaseType_t uxRand( void )
{
const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
/* Utility function to generate a pseudo random number. */
- ulNextRand = (ulMultiplier * ulNextRand) + ulIncrement;
- return((int)(ulNextRand >> 16UL) & 0x7fffUL);
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
BaseType_t xApplicationGetRandomNumber()
@@ -327,15 +325,15 @@ BaseType_t xApplicationGetRandomNumber()
* THAT RETURNS A PSEUDO RANDOM NUMBER SO IS NOT INTENDED FOR USE IN PRODUCTION
* SYSTEMS.
*/
-extern uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort)
+extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- (void)ulSourceAddress;
- (void)usSourcePort;
- (void)ulDestinationAddress;
- (void)usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
return uxRand();
-}
\ No newline at end of file
+}
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.c
deleted file mode 100644
index 317861888f..0000000000
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-/*
- * Logging utility that allows FreeRTOS tasks to log to a UDP port, stdout, and
- * disk file without making any Win32 system calls themselves.
- *
- * Messages logged to a UDP port are sent directly (using FreeRTOS+TCP), but as
- * FreeRTOS tasks cannot make Win32 system calls messages sent to stdout or a
- * disk file are sent via a stream buffer to a Win32 thread which then performs
- * the actual output.
- */
-
-/* Standard includes. */
-#include
-#include
-#include
-#include
-#include
-
-/* FreeRTOS includes. */
-#include
-#include "task.h"
-
-/* FreeRTOS+TCP includes. */
-#include "FreeRTOS_IP.h"
-#include "FreeRTOS_Sockets.h"
-#include "FreeRTOS_Stream_Buffer.h"
-
-/* Demo includes. */
-#include "demo_logging.h"
-
-/*-----------------------------------------------------------*/
-
-/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
-
-/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
-
-/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
-
-/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
-
-/*-----------------------------------------------------------*/
-
-/*
- * Called from vLoggingInit() to start a new disk log file.
- */
-static void prvFileLoggingInit( void );
-
-/*
- * Attempt to write a message to the file.
- */
-static void prvLogToFile( const char *pcMessage, size_t xLength );
-
-/*
- * Simply close the logging file, if it is open.
- */
-static void prvFileClose( void );
-
-/*
- * Before the scheduler is started this function is called directly. After the
- * scheduler has started it is called from the Windows thread dedicated to
- * outputting log messages. Only the windows thread actually performs the
- * writing so as not to disrupt the simulation by making Windows system calls
- * from FreeRTOS tasks.
- */
-static void prvLoggingFlushBuffer( void );
-
-/*
- * The windows thread that performs the actual writing of messages that require
- * Win32 system calls. Only the windows thread can make system calls so as not
- * to disrupt the simulation by making Windows calls from FreeRTOS tasks.
- */
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
-
-/*
- * Creates the socket to which UDP messages are sent. This function is not
- * called directly to prevent the print socket being created from within the IP
- * task - which could result in a deadlock. Instead the function call is
- * deferred to run in the RTOS daemon task - hence it prototype.
- */
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
-
-/*-----------------------------------------------------------*/
-
-/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
-
-/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
-
-/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
-
-/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
-
-/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
-
-/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
-
-/* Keep the current file size in a variable, as an optimisation. */
-static size_t ulSizeOfLoggingFile = 0ul;
-
-/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
-struct freertos_sockaddr xPrintUDPAddress;
-
-/*-----------------------------------------------------------*/
-
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
-{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialise it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialised. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
-}
-/*-----------------------------------------------------------*/
-
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
-{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
-
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
-
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
-
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
-
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
-}
-/*-----------------------------------------------------------*/
-
-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;
-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( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- 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 "ip" */
- }
- }
-
- /* 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( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* 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 initialised 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. */
- 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 );
- }
- }
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLoggingFlushBuffer( void )
-{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- printf( "%s", cPrintString ); /*_RB_ Replace with _write(). */
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
-}
-/*-----------------------------------------------------------*/
-
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
-{
-const DWORD xMaxWait = 1000;
-
- ( void ) pvParameter;
-
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
-
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
-
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileLoggingInit( void )
-{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvFileClose( void )
-{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvLogToFile( const char *pcMessage, size_t xLength )
-{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
-}
-/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.h
deleted file mode 100644
index ababb064e6..0000000000
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Logging/demo_logging.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef DEMO_LOGGING_H
-#define DEMO_LOGGING_H
-
-/*
- * Initialise a logging system that can be used from FreeRTOS tasks and Win32
- * threads. Do not call printf() directly while the scheduler is running.
- *
- * Set xLogToStdout, xLogToFile and xLogToUDP to either pdTRUE or pdFALSE to
- * lot to stdout, a disk file and a UDP port respectively.
- *
- * If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
- * to the IP address and port number to which UDP log messages will be sent.
- */
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
-
-#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj
index 26fbc83398..78b6c8c559 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj
@@ -62,7 +62,7 @@
Disabled
- .\Logging;.\Config;.\Test_Code\Test_Cases\include;..\..\..\CMock\vendor\unity\extras\fixture\src;..\..\..\..\Source\FreeRTOS-Plus-FAT\include;..\..\..\..\Source\FreeRTOS-Plus-FAT\portable\common;..\..\..\..\Source\FreeRTOS-Plus-TCP\protocols\include;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\Source\FreeRTOS-Plus-TCP\include;..\..\..\CMock\vendor\unity\extras\memory\src;.\DemoTasks\include;.\WinPCap;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\FreeRTOS-Plus-CLI;..\..\..\CMock\vendor\unity\src;.\TraceMacros\Example1;.;%(AdditionalIncludeDirectories)
+ ..\..\..\..\Source\Logging;.\Config;.\Test_Code\Test_Cases\include;..\..\..\CMock\vendor\unity\extras\fixture\src;..\..\..\..\Source\FreeRTOS-Plus-FAT\include;..\..\..\..\Source\FreeRTOS-Plus-FAT\portable\common;..\..\..\..\Source\FreeRTOS-Plus-TCP\protocols\include;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\..\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\..\Source\FreeRTOS-Plus-TCP\include;..\..\..\CMock\vendor\unity\extras\memory\src;.\DemoTasks\include;.\WinPCap;..\..\..\..\..\FreeRTOS\Source\include;..\..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\..\Source\FreeRTOS-Plus-CLI;..\..\..\CMock\vendor\unity\src;.\TraceMacros\Example1;.;%(AdditionalIncludeDirectories)
WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0600;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
EnableFastChecks
@@ -162,7 +162,7 @@
-
+
%(AdditionalIncludeDirectories)
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj.filters b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj.filters
index f615832749..3f132263c0 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/WIN32.vcxproj.filters
@@ -120,7 +120,7 @@
Unity
-
+
Application Code
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/main.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/main.c
index f88041487e..e5072b8b28 100644
--- a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/main.c
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/main.c
@@ -1,5 +1,5 @@
/*
-* FreeRTOS
+ * FreeRTOS
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -23,12 +23,12 @@
* http://www.FreeRTOS.org
*/
- /**
- * @file main.c
- * @brief Implements the main function.
- */
+/**
+ * @file main.c
+ * @brief Implements the main function.
+ */
- /* FreeRTOS include. */
+/* FreeRTOS include. */
#include
#include "task.h"
@@ -46,11 +46,11 @@
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_DHCP.h"
-#include "demo_logging.h"
+#include "logging.h"
#include "errhandlingapi.h"
-//#include "iot_system_init.h"
+/*#include "iot_system_init.h" */
-//#include "aws_dev_mode_key_provisioning.h"
+/*#include "aws_dev_mode_key_provisioning.h" */
/* Unity includes. */
#include "unity.h"
@@ -64,8 +64,8 @@
#define TEST_RUNNER_TASK_STACK_SIZE 10000
#define FIRST_EXCEPTION_HANDLER 1
- /* Windows-NT VectoredHandler callback function. */
-static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo);
+/* Windows-NT VectoredHandler callback function. */
+static LONG CALLBACK prvExceptionHandler( _In_ PEXCEPTION_POINTERS ExceptionInfo );
jmp_buf xMark; /* Address for long jump to jump to. */
/*-----------------------------------------------------------*/
@@ -78,7 +78,7 @@ static BaseType_t xTraceRunning = pdTRUE;
* to and from a real network connection on the host PC. See the
* configNETWORK_INTERFACE_TO_USE definition for information on how to configure
* the real network connection to use. */
-const uint8_t ucMACAddress[6] =
+const uint8_t ucMACAddress[ 6 ] =
{
configMAC_ADDR0,
configMAC_ADDR1,
@@ -93,28 +93,28 @@ const uint8_t ucMACAddress[6] =
* 1 but a DHCP server could not be contacted. See the online documentation for
* more information. In both cases the node can be discovered using
* "ping RTOSDemo". */
-static const uint8_t ucIPAddress[4] =
+static const uint8_t ucIPAddress[ 4 ] =
{
configIP_ADDR0,
configIP_ADDR1,
configIP_ADDR2,
configIP_ADDR3
};
-static const uint8_t ucNetMask[4] =
+static const uint8_t ucNetMask[ 4 ] =
{
configNET_MASK0,
configNET_MASK1,
configNET_MASK2,
configNET_MASK3
};
-static const uint8_t ucGatewayAddress[4] =
+static const uint8_t ucGatewayAddress[ 4 ] =
{
configGATEWAY_ADDR0,
configGATEWAY_ADDR1,
configGATEWAY_ADDR2,
configGATEWAY_ADDR3
};
-static const uint8_t ucDNSServerAddress[4] =
+static const uint8_t ucDNSServerAddress[ 4 ] =
{
configDNS_SERVER_ADDR0,
configDNS_SERVER_ADDR1,
@@ -126,10 +126,10 @@ static const uint8_t ucDNSServerAddress[4] =
static UBaseType_t ulNextRand;
/*-----------------------------------------------------------*/
-int main(void)
+int main( void )
{
/* Register the Windows VEH for exceptions. */
- AddVectoredExceptionHandler(FIRST_EXCEPTION_HANDLER, prvExceptionHandler);
+ AddVectoredExceptionHandler( FIRST_EXCEPTION_HANDLER, prvExceptionHandler );
/* Initialize logging for libraries that depend on it. */
vLoggingInit(
@@ -137,7 +137,7 @@ int main(void)
pdFALSE,
pdFALSE,
0,
- 0);
+ 0 );
/* Initialize the network interface.
*
@@ -146,13 +146,13 @@ int main(void)
* vApplicationIPNetworkEventHook() below). The address values passed in here
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
* but a DHCP server cannot be contacted. */
- FreeRTOS_printf(("FreeRTOS_IPInit\n"));
+ FreeRTOS_printf( ( "FreeRTOS_IPInit\n" ) );
FreeRTOS_IPInit(
ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
- ucMACAddress);
+ ucMACAddress );
vTaskStartScheduler();
@@ -160,18 +160,18 @@ int main(void)
}
/*-----------------------------------------------------------*/
-void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
+void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
/* If the network has just come up...*/
- if ((eNetworkEvent == eNetworkUp) && (xTasksAlreadyCreated == pdFALSE))
+ if( ( eNetworkEvent == eNetworkUp ) && ( xTasksAlreadyCreated == pdFALSE ) )
{
- xTaskCreate(TEST_RUNNER_RunTests_task,
- "TestRunner",
- TEST_RUNNER_TASK_STACK_SIZE,
- NULL,
- tskIDLE_PRIORITY, NULL);
+ xTaskCreate( TEST_RUNNER_RunTests_task,
+ "TestRunner",
+ TEST_RUNNER_TASK_STACK_SIZE,
+ NULL,
+ tskIDLE_PRIORITY, NULL );
xTasksAlreadyCreated = pdTRUE;
}
@@ -179,7 +179,7 @@ void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
/*-----------------------------------------------------------*/
-static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo)
+static LONG CALLBACK prvExceptionHandler( _In_ PEXCEPTION_POINTERS ExceptionInfo )
{
/* Remove warning about unused parameter */
( void ) ExceptionInfo;
@@ -195,48 +195,48 @@ static LONG CALLBACK prvExceptionHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo)
( ipconfigUSE_NBNS != 0 ) || \
( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) )
-const char* pcApplicationHostnameHook(void)
-{
- /* This function will be called during the DHCP: the machine will be registered
- * with an IP address plus this name. */
- return mainHOST_NAME;
-}
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* This function will be called during the DHCP: the machine will be registered
+ * with an IP address plus this name. */
+ return mainHOST_NAME;
+ }
#endif /* if ( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) ) */
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
-BaseType_t xApplicationDNSQueryHook(const char* pcName)
-{
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- * to this node: that returned by pcApplicationHostnameHook() and that set
- * by mainDEVICE_NICK_NAME. */
- if (_stricmp(pcName, pcApplicationHostnameHook()) == 0)
- {
- xReturn = pdPASS;
- }
- else if (_stricmp(pcName, mainDEVICE_NICK_NAME) == 0)
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
{
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
+ BaseType_t xReturn;
- return xReturn;
-}
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
-void vApplicationIdleHook(void)
+void vApplicationIdleHook( void )
{
const uint32_t ulMSToSleep = 1;
- const TickType_t xKitHitCheckPeriod = pdMS_TO_TICKS(1000UL);
+ const TickType_t xKitHitCheckPeriod = pdMS_TO_TICKS( 1000UL );
static TickType_t xTimeNow, xLastTimeCheck = 0;
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
@@ -249,19 +249,17 @@ void vApplicationIdleHook(void)
* because it is the responsibility of the idle task to clean up memory
* allocated by the kernel to any task that has since deleted itself. */
- /* _kbhit() is a Windows system function, and system functions can cause
- * crashes if they somehow block the FreeRTOS thread. The call to _kbhit()
- * can be removed if it causes problems. Limiting the frequency of calls to
- * _kbhit() should minimize the potential for issues. */
+ /* _kbhit() is a Windows system function, and system functions can cause
+ * crashes if they somehow block the FreeRTOS thread. The call to _kbhit()
+ * can be removed if it causes problems. Limiting the frequency of calls to
+ * _kbhit() should minimize the potential for issues. */
xTimeNow = xTaskGetTickCount();
- if ((xTimeNow - xLastTimeCheck) > xKitHitCheckPeriod)
+ if( ( xTimeNow - xLastTimeCheck ) > xKitHitCheckPeriod )
{
-
-
/* Uncomment the print line to get confirmation that tests are still
* running if you suspect a previous run resulted in a crash. */
- /* configPRINTF( ( "Running...\n" ) ); /**/
+ /* configPRINTF( ( "Running...\n" ) ); /**/
xLastTimeCheck = xTimeNow;
}
@@ -269,42 +267,42 @@ void vApplicationIdleHook(void)
* cycle of the idle task if configUSE_IDLE_HOOK is set to 1 in
* FreeRTOSConfig.h. It must *NOT* attempt to block. In this case the
* idle task just sleeps to lower the CPU usage. */
- Sleep(ulMSToSleep);
+ Sleep( ulMSToSleep );
}
/*-----------------------------------------------------------*/
-void vAssertCalled(const char* pcFile,
- uint32_t ulLine)
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
const uint32_t ulLongSleep = 1000UL;
volatile uint32_t ulBlockVariable = 0UL;
- volatile char* pcFileName = (volatile char*)pcFile;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
volatile uint32_t ulLineNumber = ulLine;
- (void)pcFileName;
- (void)ulLineNumber;
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
- printf("vAssertCalled %s, %ld\n", pcFile, (long)ulLine);
- fflush(stdout);
+ printf( "vAssertCalled %s, %ld\n", pcFile, ( long ) ulLine );
+ fflush( stdout );
/* Setting ulBlockVariable to a non-zero value in the debugger will allow
* this function to be exited. */
taskDISABLE_INTERRUPTS();
{
- while (ulBlockVariable == 0UL)
+ while( ulBlockVariable == 0UL )
{
- Sleep(ulLongSleep);
+ Sleep( ulLongSleep );
}
}
taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
-void getUserCmd(char* pucUserCmd)
+void getUserCmd( char * pucUserCmd )
{
char cTmp;
- scanf("%c%c", pucUserCmd, &cTmp);
+ scanf( "%c%c", pucUserCmd, &cTmp );
}
/*-----------------------------------------------------------*/
@@ -314,11 +312,11 @@ UBaseType_t uxRand( void )
/* Utility function to generate a pseudo random number. */
- ulNextRand = (ulMultiplier * ulNextRand) + ulIncrement;
- return((int)(ulNextRand) & 0x7fffUL);
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand ) & 0x7fffUL );
}
-BaseType_t xApplicationGetRandomNumber( uint32_t* pulNumber )
+BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
*pulNumber = uxRand();
@@ -331,15 +329,15 @@ BaseType_t xApplicationGetRandomNumber( uint32_t* pulNumber )
* THAT RETURNS A PSEUDO RANDOM NUMBER SO IS NOT INTENDED FOR USE IN PRODUCTION
* SYSTEMS.
*/
-extern uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort)
+extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- (void)ulSourceAddress;
- (void)usSourcePort;
- (void)ulDestinationAddress;
- (void)usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
return uxRand();
-}
\ No newline at end of file
+}
diff --git a/FreeRTOS/Demo/Posix_GCC/main_networking.c b/FreeRTOS/Demo/Posix_GCC/main_networking.c
index 067c8e4c12..2265c9c4d7 100644
--- a/FreeRTOS/Demo/Posix_GCC/main_networking.c
+++ b/FreeRTOS/Demo/Posix_GCC/main_networking.c
@@ -47,37 +47,37 @@
/*#include "SimpleUDPClientAndServer.h" */
/*#include "SimpleTCPEchoServer.h" */
/*#include "TCPEchoClient_SingleTasks.h" */
-/*#include "demo_logging.h" */
+/*#include "logging.h" */
#include "TCPEchoClient_SingleTasks.h"
/* Simple UDP client and server task parameters. */
-#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
-#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
+#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
+#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
/* Echo client task parameters - used for both TCP and UDP echo clients. */
-#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the linux port. */
-#define mainECHO_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the linux port. */
+#define mainECHO_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* Echo server task parameters. */
-#define mainECHO_SERVER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the linux port. */
-#define mainECHO_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#define mainECHO_SERVER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the linux port. */
+#define mainECHO_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* Define a name that will be used for LLMNR and NBNS searches. */
-#define mainHOST_NAME "RTOSDemo"
-#define mainDEVICE_NICK_NAME "linux_demo"
+#define mainHOST_NAME "RTOSDemo"
+#define mainDEVICE_NICK_NAME "linux_demo"
/* Set the following constants to 1 or 0 to define which tasks to include and
-exclude:
-
-mainCREATE_TCP_ECHO_TASKS_SINGLE: When set to 1 a set of tasks are created that
-send TCP echo requests to the standard echo port (port 7), then wait for and
-verify the echo reply, from within the same task (Tx and Rx are performed in the
-same RTOS task). The IP address of the echo server must be configured using the
-configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
-FreeRTOSConfig.h.
-
-*/
-#define mainCREATE_TCP_ECHO_TASKS_SINGLE 1
+ * exclude:
+ *
+ * mainCREATE_TCP_ECHO_TASKS_SINGLE: When set to 1 a set of tasks are created that
+ * send TCP echo requests to the standard echo port (port 7), then wait for and
+ * verify the echo reply, from within the same task (Tx and Rx are performed in the
+ * same RTOS task). The IP address of the echo server must be configured using the
+ * configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
+ * FreeRTOSConfig.h.
+ *
+ */
+#define mainCREATE_TCP_ECHO_TASKS_SINGLE 1
/*-----------------------------------------------------------*/
/*
@@ -92,28 +92,28 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
@@ -121,172 +121,172 @@ static UBaseType_t ulNextRand;
/*-----------------------------------------------------------*/
-void main_tcp_echo_client_tasks( void )
+void main_tcp_echo_client_tasks( void )
{
-const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL );
-
- /*
- * Instructions for using this project are provided on:
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
- */
-
- /* Miscellaneous initialisation including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialise the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the definition of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
- FreeRTOS_IPInit( ucIPAddress,
- ucNetMask,
- ucGatewayAddress,
- ucDNSServerAddress,
- ucMACAddress );
-
- /* Start the RTOS scheduler. */
- FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
- vTaskStartScheduler();
- FreeRTOS_debug_printf( ( "Should not reach this point after scheduler\n" ) );
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not not
- really applicable to the Linux simulator port). */
- for( ; ; )
- {
- usleep( ulLongTime_ms * 1000 );
- }
+ const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL );
+
+ /*
+ * Instructions for using this project are provided on:
+ * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
+ */
+
+ /* Miscellaneous initialisation including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialise the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the definition of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
+ FreeRTOS_IPInit( ucIPAddress,
+ ucNetMask,
+ ucGatewayAddress,
+ ucDNSServerAddress,
+ ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
+ vTaskStartScheduler();
+ FreeRTOS_debug_printf( ( "Should not reach this point after scheduler\n" ) );
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not not
+ * really applicable to the Linux simulator port). */
+ for( ; ; )
+ {
+ usleep( ulLongTime_ms * 1000 );
+ }
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* See the comments above the definitions of these pre-processor
- macros at the top of this file for a description of the individual
- demo tasks. */
-
- #if ( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )
- {
- vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );
- }
- #endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */
-
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
- else
- {
- FreeRTOS_printf( "Application idle hook network down\n" );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* See the comments above the definitions of these pre-processor
+ * macros at the top of this file for a description of the individual
+ * demo tasks. */
+
+ #if ( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )
+ {
+ vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );
+ }
+ #endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */
+
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
+ else
+ {
+ FreeRTOS_printf( "Application idle hook network down\n" );
+ }
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
- /* Utility function to generate a pseudo random number. */
+ /* Utility function to generate a pseudo random number. */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-
- /* Seed the random number generator. */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n",
- ipconfigRAND32(),
- ipconfigRAND32(),
- ipconfigRAND32(),
- ipconfigRAND32() ) );
+ time_t xTimeNow;
+
+ /* Seed the random number generator. */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n",
+ ipconfigRAND32(),
+ ipconfigRAND32(),
+ ipconfigRAND32(),
+ ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( strcasecmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( strcasecmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( strcasecmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( strcasecmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
@@ -297,16 +297,16 @@ time_t xTimeNow;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*
@@ -316,6 +316,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
*/
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *( pulNumber ) = uxRand();
- return pdTRUE;
+ *( pulNumber ) = uxRand();
+ return pdTRUE;
}