--- /dev/null
+/*\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
+\r
+//_RB_ Add link to docs here.\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Standard includes. */\r
+#include <stdio.h>\r
+\r
+/* IoT SDK includes. */\r
+#include "iot_taskpool.h"\r
+\r
+/* The priority at which that tasks in the task pool (the worker tasks) get\r
+created. */\r
+#define tpTASK_POOL_WORKER_PRIORITY 1\r
+\r
+/* The number of jobs created in the example functions that create more than\r
+one job. */\r
+#define tpJOBS_TO_CREATE 5\r
+\r
+/*\r
+ * Prototypes for the functions that demonstrate the task pool API.\r
+ * See the implementation of the prvTaskPoolDemoTask() function within this file\r
+ * for a description of the individual functions. A configASSERT() is hit if\r
+ * any of the demos encounter any unexpected behaviour.\r
+ */\r
+static void prvExample_BasicSingleJob( void );\r
+static void prvExample_DeferredSingleJob( void );\r
+static void prvExample_BasicRecyclableJob( void );\r
+static void prvExample_ReuseRecyclableJobFromLowPriorityTask( void );\r
+static void prvExample_ReuseRecyclableJobFromHighPriorityTask( void );\r
+\r
+/*\r
+ * Prototypes of the callback functions used in the examples. The callback\r
+ * simply sends a signal (in the form of a direct task notification) to the\r
+ * prvTaskPoolDemoTask() task to let the task know that the callback execute.\r
+ * The handle of the prvTaskPoolDemoTask() task is not accessed directly, but\r
+ * instead passed into the task pool job as the job's context.\r
+ */\r
+static void prvSimpleTaskNotifyCallback( IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pUserContext );\r
+\r
+/*\r
+ * The task used to demonstrate the task pool API. This task just loops through\r
+ * each demo in turn.\r
+ */\r
+static void prvTaskPoolDemoTask( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Parameters used to create the system task pool - see TBD for more information\r
+as the task pool used in this example is a slimmed down version of the full\r
+library - the slimmed down version being intended specifically for FreeRTOS\r
+kernel use cases. */\r
+static const IotTaskPoolInfo_t xTaskPoolParameters = {\r
+ /* Minimum number of threads in a task pool.\r
+ Note the slimmed down version of the task\r
+ pool used by this library does not autoscale\r
+ the number of tasks in the pool so in this\r
+ case this sets the number of tasks in the\r
+ pool. */\r
+ 2,\r
+ /* Maximum number of threads in a task pool.\r
+ Note the slimmed down version of the task\r
+ pool used by this library does not autoscale\r
+ the number of tasks in the pool so in this\r
+ case this parameter is just ignored. */\r
+ 2,\r
+ /* Stack size for every task pool thread - in\r
+ bytes, hence multiplying by the number of bytes\r
+ in a word as configMINIMAL_STACK_SIZE is\r
+ specified in words. */\r
+ configMINIMAL_STACK_SIZE * sizeof( portSTACK_TYPE ),\r
+ /* Priority for every task pool thread. */\r
+ tpTASK_POOL_WORKER_PRIORITY,\r
+ };\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vStartSimpleTaskPoolDemo( void )\r
+{\r
+ /* This example uses a single application task, which in turn is used to\r
+ create and send jobs to task pool tasks. */\r
+ xTaskCreate( prvTaskPoolDemoTask, /* Function that implements the task. */\r
+ "PoolDemo", /* Text name for the task - only used for debugging. */\r
+ configMINIMAL_STACK_SIZE, /* Size of stack (in words, not bytes) to allocate for the task. */\r
+ NULL, /* Task parameter - not used in this case. */\r
+ tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */\r
+ NULL ); /* Used to pass out a handle to the created tsak - not used in this case. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTaskPoolDemoTask( void *pvParameters )\r
+{\r
+IotTaskPoolError_t xResult;\r
+uint32_t ulLoops = 0;\r
+\r
+ /* Remove compiler warnings about unused parameters. */\r
+ ( void ) pvParameters;\r
+\r
+ /* The task pool must be created before it can be used. The system task\r
+ pool is the task pool managed by the task pool library itself - the storage\r
+ used by the task pool is provided by the library. */\r
+ xResult = IotTaskPool_CreateSystemTaskPool( &xTaskPoolParameters );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* Attempting to create the task pool again should then appear to succeed\r
+ (in case it is initialised by more than one library), but have no effect. */\r
+ xResult = IotTaskPool_CreateSystemTaskPool( &xTaskPoolParameters );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ for( ;; )\r
+ {\r
+ /* Demonstrate the most basic use case where a non persistent job is\r
+ created and scheduled to run immediately. The task pool worker tasks\r
+ (in which the job callback function executes) have a priority above the\r
+ priority of this task so the job's callback executes as soon as it is\r
+ scheduled. */\r
+ prvExample_BasicSingleJob();\r
+\r
+ /* Demonstrate a job being scheduled to run at some time in the\r
+ future, and how a job scheduled to run in the future can be cancelled if\r
+ it has not yet started executing. */\r
+ prvExample_DeferredSingleJob();\r
+\r
+ /* Demonstrate the most basic use of a recyclable job. This is similar\r
+ to prvExample_BasicSingleJob() but using a recyclable job. Creating a\r
+ recyclable job will re-use a previously created and now spare job from\r
+ the task pool's job cache if one is available, or otherwise dynamically\r
+ create a new job if a spare job is not available in the cache but space\r
+ remains in the cache. */\r
+ prvExample_BasicRecyclableJob();\r
+\r
+ /* Demonstrate multiple recyclable jobs being created, used, and then\r
+ re-used. In this the task pool worker tasks (in which the job callback\r
+ functions execute) have a priority above the priority of this task so\r
+ the job's callback functions execute as soon as they are scheduled. */\r
+ prvExample_ReuseRecyclableJobFromLowPriorityTask();\r
+\r
+ /* Again demonstrate multiple recyclable jobs being used, but this time\r
+ the priority of the task pool worker tasks (in which the job callback\r
+ functions execute) are lower than the priority of this task so the job's\r
+ callback functions don't execute until this task enteres the blocked\r
+ state. */\r
+ prvExample_ReuseRecyclableJobFromHighPriorityTask();\r
+\r
+ ulLoops++;\r
+ if( ( ulLoops % 10UL ) == 0 )\r
+ {\r
+ printf( "prvTaskPoolDemoTask() performed %u iterations without hitting an assert.\r\n", ulLoops );\r
+ fflush( stdout );\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSimpleTaskNotifyCallback( IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pUserContext )\r
+{\r
+TaskHandle_t xTaskToNotify = ( TaskHandle_t ) pUserContext;\r
+\r
+ /* Remove warnings about unused parameters. */\r
+ ( void ) pTaskPool;\r
+ ( void ) pJob;\r
+\r
+ /* Notify the task that created this job. */\r
+ xTaskNotifyGive( xTaskToNotify );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExample_BasicSingleJob( void )\r
+{\r
+IotTaskPoolJobStorage_t xJobStorage;\r
+IotTaskPoolJob_t xJob;\r
+IotTaskPoolError_t xResult;\r
+uint32_t ulReturn;\r
+const uint32_t ulNoFlags = 0UL;\r
+const TickType_t xNoDelay = ( TickType_t ) 0;\r
+size_t xFreeHeapBeforeCreatingJob = xPortGetFreeHeapSize();\r
+IotTaskPoolJobStatus_t xJobStatus;\r
+\r
+ /* Don't expect any notifications to be pending yet. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* Create and schedule a job using the handle of this task as the job's\r
+ context and the function that sends a notification to the task handle as\r
+ the jobs callback function. This is not a recyclable job so the storage\r
+ required to hold information about the job is provided by this task - in\r
+ this case the storage is on the stack of this task so no memory is allocated\r
+ dynamically but the stack frame must remain in scope for the lifetime of\r
+ the job. */\r
+ xResult = IotTaskPool_CreateJob( prvSimpleTaskNotifyCallback, /* Callback function. */\r
+ ( void * ) xTaskGetCurrentTaskHandle(), /* Job context. */\r
+ &xJobStorage,\r
+ &xJob );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* The job has been created but not scheduled so is now ready. */\r
+ IotTaskPool_GetStatus( NULL, xJob, &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_READY );\r
+\r
+ /* This is not a persistent (recyclable) job and its storage is on the\r
+ stack of this function, so the amount of heap space available should not\r
+ have chanced since entering this function. */\r
+ configASSERT( xFreeHeapBeforeCreatingJob == xPortGetFreeHeapSize() );\r
+\r
+ /* In the full task pool implementation the first parameter is used to\r
+ pass the handle of the task pool to schedule. The lean task pool\r
+ implementation used in this demo only supports a single task pool, which\r
+ is created internally within the library, so the first parameter is NULL. */\r
+ xResult = IotTaskPool_Schedule( NULL, xJob, ulNoFlags );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* Look for the notification coming from the job's callback function. The\r
+ priority of the task pool worker task that executes the callback is higher\r
+ than the priority of this task so a block time is not needed - the task pool\r
+ worker task pre-empts this task and sends the notification (from the job's\r
+ callback) as soon as the job is scheduled. */\r
+ ulReturn = ulTaskNotifyTake( pdTRUE, xNoDelay );\r
+ configASSERT( ulReturn );\r
+\r
+ /* The job's callback has executed so the job has now completed. */\r
+ IotTaskPool_GetStatus( NULL, xJob, &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_COMPLETED );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExample_DeferredSingleJob( void )\r
+{\r
+IotTaskPoolJobStorage_t xJobStorage;\r
+IotTaskPoolJob_t xJob;\r
+IotTaskPoolError_t xResult;\r
+uint32_t ulReturn;\r
+const uint32_t ulShortDelay_ms = 100UL;\r
+const TickType_t xNoDelay = ( TickType_t ) 0, xAllowableMargin = ( TickType_t ) 5; /* Large margin for Windows port, which is not real time. */\r
+TickType_t xTimeBefore, xElapsedTime, xShortDelay_ticks;\r
+size_t xFreeHeapBeforeCreatingJob = xPortGetFreeHeapSize();\r
+IotTaskPoolJobStatus_t xJobStatus;\r
+\r
+ /* Don't expect any notifications to be pending yet. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* Create a job using the handle of this task as the job's context and the\r
+ function that sends a notification to the task handle as the jobs callback\r
+ function. The job is created using storage allocated on the stack of this\r
+ function - so no memory is allocated. */\r
+ xResult = IotTaskPool_CreateJob( prvSimpleTaskNotifyCallback, /* Callback function. */\r
+ ( void * ) xTaskGetCurrentTaskHandle(), /* Job context. */\r
+ &xJobStorage,\r
+ &xJob );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* The job has been created but not scheduled so is now ready. */\r
+ IotTaskPool_GetStatus( NULL, xJob, &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_READY );\r
+\r
+ /* This is not a persistent (recyclable) job and its storage is on the\r
+ stack of this function, so the amount of heap space available should not\r
+ have chanced since entering this function. */\r
+ configASSERT( xFreeHeapBeforeCreatingJob == xPortGetFreeHeapSize() );\r
+\r
+ /* Schedule the job to run its callback in xShortDelay_ms milliseconds time.\r
+ In the full task pool implementation the first parameter is used to pass the\r
+ handle of the task pool to schedule. The lean task pool implementation used\r
+ in this demo only supports a single task pool, which is created internally\r
+ within the library, so the first parameter is NULL. */\r
+ xResult = IotTaskPool_ScheduleDeferred( NULL, xJob, ulShortDelay_ms );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* The scheduled job should not have executed yet, so don't expect any\r
+ notifications and expect the job's status to be 'deferred'. */\r
+ ulReturn = ulTaskNotifyTake( pdTRUE, xNoDelay );\r
+ configASSERT( ulReturn == 0 );\r
+ IotTaskPool_GetStatus( NULL, xJob, &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_DEFERRED );\r
+\r
+ /* As the job has not yet been executed it can be stopped. */\r
+ xResult = IotTaskPool_TryCancel( NULL, xJob, &xJobStatus );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+ IotTaskPool_GetStatus( NULL, xJob, &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_CANCELED );\r
+\r
+ /* Schedule the job again, and this time wait until its callback is\r
+ executed (the callback function sends a notification to this task) to see\r
+ that it executes at the right time. */\r
+ xTimeBefore = xTaskGetTickCount();\r
+ xResult = IotTaskPool_ScheduleDeferred( NULL, xJob, ulShortDelay_ms );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* Wait twice the deferred execution time to ensure the callback is executed\r
+ before the call below times out. */\r
+ ulReturn = ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( ulShortDelay_ms * 2UL ) );\r
+ xElapsedTime = xTaskGetTickCount() - xTimeBefore;\r
+\r
+ /* A single notification should not have been received... */\r
+ configASSERT( ulReturn == 1 );\r
+\r
+ /* ...and the time since scheduling the job should be greater than or\r
+ equal to the deferred execution time - which is converted to ticks for\r
+ comparison. */\r
+ xShortDelay_ticks = pdMS_TO_TICKS( ulShortDelay_ms );\r
+ configASSERT( ( xElapsedTime >= xShortDelay_ticks ) && ( xElapsedTime < ( xShortDelay_ticks + xAllowableMargin ) ) );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExample_BasicRecyclableJob( void )\r
+{\r
+IotTaskPoolJob_t xJob;\r
+IotTaskPoolError_t xResult;\r
+uint32_t ulReturn;\r
+const uint32_t ulNoFlags = 0UL;\r
+const TickType_t xNoDelay = ( TickType_t ) 0;\r
+size_t xFreeHeapBeforeCreatingJob = xPortGetFreeHeapSize();\r
+\r
+ /* Don't expect any notifications to be pending yet. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* Create and schedule a job using the handle of this task as the job's\r
+ context and the function that sends a notification to the task handle as\r
+ the jobs callback function. The job is created as a recyclable job and in\r
+ this case the memory used to hold the job status is allocated inside the\r
+ create function. As the job is persistent it can be used multiple times,\r
+ as demonstrated in other examples within this demo. In the full task pool\r
+ implementation the first parameter is used to pass the handle of the task\r
+ pool this recyclable job is to be associated with. In the lean\r
+ implementation of the task pool used by this demo there is only one task\r
+ pool (the system task pool created within the task pool library) so the\r
+ first parameter is NULL. */\r
+ xResult = IotTaskPool_CreateRecyclableJob( NULL,\r
+ prvSimpleTaskNotifyCallback,\r
+ (void * ) xTaskGetCurrentTaskHandle(),\r
+ &xJob );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* This recyclable job is persistent, and in this case created dynamically,\r
+ so expect there to be less heap space then when entering the function. */\r
+ configASSERT( xPortGetFreeHeapSize() < xFreeHeapBeforeCreatingJob );\r
+\r
+ /* In the full task pool implementation the first parameter is used to\r
+ pass the handle of the task pool to schedule. The lean task pool\r
+ implementation used in this demo only supports a single task pool, which\r
+ is created internally within the library, so the first parameter is NULL. */\r
+ xResult = IotTaskPool_Schedule( NULL, xJob, ulNoFlags );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* Look for the notification coming from the job's callback function. The\r
+ priority of the task pool worker task that executes the callback is higher\r
+ than the priority of this task so a block time is not needed - the task pool\r
+ worker task pre-empts this task and sends the notification (from the job's\r
+ callback) as soon as the job is scheduled. */\r
+ ulReturn = ulTaskNotifyTake( pdTRUE, xNoDelay );\r
+ configASSERT( ulReturn );\r
+\r
+ /* Clean up recyclable job. In the full implementation of the task pool\r
+ the first parameter is used to pass a handle to the task pool the job is\r
+ associated with. In the lean implementation of the task pool used by this\r
+ demo there is only one task pool (the system task pool created in the\r
+ task pool library itself) so the first parameter is NULL. */\r
+ IotTaskPool_DestroyRecyclableJob( NULL, xJob );\r
+\r
+ /* Once the job has been deleted the memory used to hold the job is\r
+ returned, so the available heap should be exactly as when entering this\r
+ function. */\r
+ configASSERT( xPortGetFreeHeapSize() == xFreeHeapBeforeCreatingJob );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExample_ReuseRecyclableJobFromLowPriorityTask( void )\r
+{\r
+IotTaskPoolError_t xResult;\r
+uint32_t x, xIndex, ulNotificationValue;\r
+const uint32_t ulNoFlags = 0UL;\r
+IotTaskPoolJob_t xJobs[ tpJOBS_TO_CREATE ];\r
+size_t xFreeHeapBeforeCreatingJob = xPortGetFreeHeapSize();\r
+IotTaskPoolJobStatus_t xJobStatus;\r
+\r
+ /* Don't expect any notifications to be pending yet. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* Create tpJOBS_TO_CREATE jobs using the handle of this task as the job's\r
+ context and the function that sends a notification to the task handle as\r
+ the jobs callback function. The jobs are created as a recyclable job and\r
+ in this case the memory to store the job information is allocated within\r
+ the create function as at this time there are no recyclable jobs in the\r
+ task pool jobs cache. As the jobs are persistent they can be used multiple\r
+ times. In the full task pool implementation the first parameter is used to\r
+ pass the handle of the task pool this recyclable job is to be associated\r
+ with. In the lean implementation of the task pool used by this demo there\r
+ is only one task pool (the system task pool created within the task pool\r
+ library) so the first parameter is NULL. */\r
+ for( x = 0; x < tpJOBS_TO_CREATE; x++ )\r
+ {\r
+ xResult = IotTaskPool_CreateRecyclableJob( NULL,\r
+ prvSimpleTaskNotifyCallback,\r
+ (void * ) xTaskGetCurrentTaskHandle(),\r
+ &( xJobs[ x ] ) );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* The job has been created but not scheduled so is now ready. */\r
+ IotTaskPool_GetStatus( NULL, xJobs[ x ], &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_READY );\r
+ }\r
+\r
+ /* Demonstrate that the jobs can be recycled by performing twice the number\r
+ of iterations of scheduling jobs than there actually are created jobs. This\r
+ works because the task pool task priorities are above the priority of this\r
+ task, so the tasks that run the jobs pre-empt this task as soon as a job is\r
+ ready. */\r
+ for( x = 0; x < ( tpJOBS_TO_CREATE * 2UL ); x++ )\r
+ {\r
+ /* Make sure array index does not go out of bounds. */\r
+ xIndex = x % tpJOBS_TO_CREATE;\r
+\r
+ xResult = IotTaskPool_Schedule( NULL, xJobs[ xIndex ], ulNoFlags );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* The priority of the task pool task(s) is higher than the priority\r
+ of this task, so the job's callback function should have already\r
+ executed, sending a notification to this task, and incrementing this\r
+ task's notification value. */\r
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ &ulNotificationValue, /* Obtain the notification value. */\r
+ 0UL ); /* No block time, return immediately. */\r
+ configASSERT( ulNotificationValue == ( x + 1 ) );\r
+\r
+ /* The job's callback has executed so the job is now completed. */\r
+ IotTaskPool_GetStatus( NULL, xJobs[ xIndex ], &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_COMPLETED );\r
+\r
+ /* To leave the list of jobs empty we can stop re-creating jobs half\r
+ way through iterations of this loop. */\r
+ if( x < tpJOBS_TO_CREATE )\r
+ {\r
+ /* Recycle the job so it can be used again. In the full task pool\r
+ implementation the first parameter is used to pass the handle of the\r
+ task pool this job will be associated with. In this lean task pool\r
+ implementation only the system task pool exists (the task pool created\r
+ internally to the task pool library) so the first parameter is just\r
+ passed as NULL. *//*_RB_ Why not recycle it automatically? */\r
+ IotTaskPool_RecycleJob( NULL, xJobs[ xIndex ] );\r
+ xResult = IotTaskPool_CreateRecyclableJob( NULL,\r
+ prvSimpleTaskNotifyCallback,\r
+ (void * ) xTaskGetCurrentTaskHandle(),\r
+ &( xJobs[ xIndex ] ) );\r
+ }\r
+ }\r
+\r
+ /* Clear all the notification value bits again. */\r
+ xTaskNotifyWait( portMAX_DELAY, /* Clear all bits on entry - portMAX_DELAY is used as it is a portable way of having all bits set. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ NULL, /* Don't need the notification value this time. */\r
+ 0UL ); /* No block time, return immediately. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* Clean up all the recyclable job. In the full implementation of the task\r
+ pool the first parameter is used to pass a handle to the task pool the job\r
+ is associated with. In the lean implementation of the task pool used by\r
+ this demo there is only one task pool (the system task pool created in the\r
+ task pool library itself) so the first parameter is NULL. */\r
+ for( x = 0; x < tpJOBS_TO_CREATE; x++ )\r
+ {\r
+ xResult = IotTaskPool_DestroyRecyclableJob( NULL, xJobs[ x ] );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+ }\r
+\r
+ /* Once the job has been deleted the memory used to hold the job is\r
+ returned, so the available heap should be exactly as when entering this\r
+ function. */\r
+ configASSERT( xPortGetFreeHeapSize() == xFreeHeapBeforeCreatingJob );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExample_ReuseRecyclableJobFromHighPriorityTask( void )\r
+{\r
+IotTaskPoolError_t xResult;\r
+uint32_t x, ulNotificationValue;\r
+const uint32_t ulNoFlags = 0UL;\r
+IotTaskPoolJob_t xJobs[ tpJOBS_TO_CREATE ];\r
+IotTaskPoolJobStorage_t xJobStorage[ tpJOBS_TO_CREATE ];\r
+size_t xFreeHeapBeforeCreatingJob = xPortGetFreeHeapSize();\r
+TickType_t xShortDelay = pdMS_TO_TICKS( 150 );\r
+IotTaskPoolJobStatus_t xJobStatus;\r
+\r
+ /* Don't expect any notifications to be pending yet. */\r
+ configASSERT( ulTaskNotifyTake( pdTRUE, 0 ) == 0 );\r
+\r
+ /* prvExample_ReuseRecyclableJobFromLowPriorityTask() executes in a task\r
+ that has a lower [task] priority than the task pool's worker tasks.\r
+ Therefore a talk pool worker preempts the task that calls\r
+ prvExample_ReuseRecyclableJobFromHighPriorityTask() as soon as the job is\r
+ scheduled. prvExample_ReuseRecyclableJobFromHighPriorityTask() reverses the\r
+ priorities - prvExample_ReuseRecyclableJobFromHighPriorityTask() raises its\r
+ priority to above the task pool's worker tasks, so the worker tasks do not\r
+ execute until the calling task enters the blocked state. First raise the\r
+ priority - passing NULL means raise the priority of the calling task. */\r
+ vTaskPrioritySet( NULL, tpTASK_POOL_WORKER_PRIORITY + 1 );\r
+\r
+ /* Create tpJOBS_TO_CREATE jobs using the handle of this task as the job's\r
+ context and the function that sends a notification to the task handle as\r
+ the jobs callback function. */\r
+ for( x = 0; x < tpJOBS_TO_CREATE; x++ )\r
+ {\r
+ xResult = IotTaskPool_CreateJob( prvSimpleTaskNotifyCallback, /* Callback function. */\r
+ ( void * ) xTaskGetCurrentTaskHandle(), /* Job context. */\r
+ &( xJobStorage[ x ] ),\r
+ &( xJobs[ x ] ) );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* This is not a persistent (recyclable) job and its storage is on the\r
+ stack of this function, so the amount of heap space available should not\r
+ have chanced since entering this function. */\r
+ configASSERT( xFreeHeapBeforeCreatingJob == xPortGetFreeHeapSize() );\r
+ }\r
+\r
+ for( x = 0; x < tpJOBS_TO_CREATE; x++ )\r
+ {\r
+ /* Schedule the next job. */\r
+ xResult = IotTaskPool_Schedule( NULL, xJobs[ x ], ulNoFlags );\r
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );\r
+\r
+ /* Although scheduled, the job's callback has not executed, so the job\r
+ reports itself as scheduled. */\r
+ IotTaskPool_GetStatus( NULL, xJobs[ x ], &xJobStatus );\r
+ configASSERT( xJobStatus == IOT_TASKPOOL_STATUS_SCHEDULED );\r
+\r
+ /* The priority of the task pool task(s) is lower than the priority\r
+ of this task, so the job's callback function should not have executed\r
+ yes, so don't expect the notification value for this task to have\r
+ changed. */\r
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ &ulNotificationValue, /* Obtain the notification value. */\r
+ 0UL ); /* No block time, return immediately. */\r
+ configASSERT( ulNotificationValue == 0 );\r
+ }\r
+\r
+ /* At this point there are tpJOBS_TO_CREATE scheduled, but none have executed\r
+ their callbacks because the priority of this task is higher than the\r
+ priority of the task pool worker threads. When this task blocks to wait for\r
+ a notification a worker thread will be able to executes - but as soon as its\r
+ callback function sends a notification to this task this task will\r
+ preempt it (because it has a higher priority) so this task only expects to\r
+ receive one notification at a time. */\r
+ for( x = 0; x < tpJOBS_TO_CREATE; x++ )\r
+ {\r
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ &ulNotificationValue, /* Obtain the notification value. */\r
+ xShortDelay ); /* Short delay to allow a task pool worker to execute. */\r
+ configASSERT( ulNotificationValue == ( x + 1 ) );\r
+ }\r
+\r
+ /* All the scheduled jobs have now executed, so waiting for another\r
+ notification should timeout without the notification value changing. */\r
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ &ulNotificationValue, /* Obtain the notification value. */\r
+ xShortDelay ); /* Short delay to allow a task pool worker to execute. */\r
+ configASSERT( ulNotificationValue == x );\r
+\r
+ /* Reset the priority of this task and clear the notifications ready for the\r
+ next example. */\r
+ vTaskPrioritySet( NULL, tskIDLE_PRIORITY );\r
+ xTaskNotifyWait( portMAX_DELAY, /* Clear all bits on entry - portMAX_DELAY is used as it is a portable way of having all bits set. */\r
+ 0UL, /* Don't clear any bits on exit. */\r
+ NULL, /* Don't need the notification value this time. */\r
+ 0UL ); /* No block time, return immediately. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
#include <stdio.h>\r
#include <time.h>\r
\r
+/* Visual studio intrinsics used so the __debugbreak() function is available\r
+should an assert get hit. */\r
+#include <intrin.h>\r
+\r
/* FreeRTOS includes. */\r
#include <FreeRTOS.h>\r
#include "task.h"\r
\r
-/* Demo application includes. */\r
+/* TCP/IP stack includes. */\r
#include "FreeRTOS_IP.h"\r
-#include "FreeRTOS_Sockets.h"\r
-#include "SimpleUDPClientAndServer.h"\r
-#include "demo_logging.h"\r
-\r
-/* Simple UDP client and server task parameters. */\r
-#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )\r
-#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )\r
-\r
-/* Define a name that will be used for LLMNR and NBNS searches. */\r
-#define mainHOST_NAME "RTOSDemo"\r
-#define mainDEVICE_NICK_NAME "windows_demo"\r
-\r
-/* Set the following constants to 1 or 0 to define which tasks to include and\r
-exclude:\r
-\r
-mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS: When set to 1 two UDP client tasks\r
-and two UDP server tasks are created. The clients talk to the servers. One set\r
-of tasks use the standard sockets interface, and the other the zero copy sockets\r
-interface. These tasks are self checking and will trigger a configASSERT() if\r
-they detect a difference in the data that is received from that which was sent.\r
-As these tasks use UDP, and can therefore loose packets, they will cause\r
-configASSERT() to be called when they are run in a less than perfect networking\r
-environment.\r
-\r
-mainCREATE_TCP_ECHO_TASKS_SINGLE: When set to 1 a set of tasks are created that\r
-send TCP echo requests to the standard echo port (port 7), then wait for and\r
-verify the echo reply, from within the same task (Tx and Rx are performed in the\r
-same RTOS task). The IP address of the echo server must be configured using the\r
-configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in\r
-FreeRTOSConfig.h.\r
-\r
-mainCREATE_TCP_ECHO_SERVER_TASK: When set to 1 a task is created that accepts\r
-connections on the standard echo port (port 7), then echos back any data\r
-received on that connection.\r
-*/\r
-#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1\r
-/*-----------------------------------------------------------*/\r
-\r
-/*\r
- * Just seeds the simple pseudo random number generator.\r
- */\r
-static void prvSRand( UBaseType_t ulSeed );\r
\r
/*\r
- * Miscellaneous initialisation including preparing the logging and seeding the\r
- * random number generator.\r
+ * Prototypes for the demos that can be started from this project.\r
*/\r
-static void prvMiscInitialisation( void );\r
+extern void vStartSimpleTaskPoolDemo( void );\r
\r
-/* The default IP and MAC address used by the demo. The address configuration\r
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is\r
-1 but a DHCP server could not be contacted. See the online documentation for\r
-more information. */\r
-static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };\r
-static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };\r
-static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };\r
-static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };\r
-\r
-/* Set the following constant to pdTRUE to log using the method indicated by the\r
-name of the constant, or pdFALSE to not log using the method indicated by the\r
-name of the constant. Options include to standard out (xLogToStdout), to a disk\r
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE\r
-then UDP messages are sent to the IP address configured as the echo server\r
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and\r
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */\r
-const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;\r
-\r
-/* Default MAC address configuration. The demo creates a virtual network\r
-connection that uses this MAC address by accessing the raw Ethernet data\r
-to and from a real network connection on the host PC. See the\r
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure\r
-the real network connection to use. */\r
+/* This example is the first in a sequence that adds IoT functionality into\r
+an existing TCP/IP project. In this first project the TCP/IP stack is not\r
+actually used, but it is still built, which requires this array to be\r
+present. */\r
const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };\r
\r
-/* Use by the pseudo random number generator. */\r
-static UBaseType_t ulNextRand;\r
-\r
/*-----------------------------------------------------------*/\r
\r
int main( void )\r
{\r
-const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL );\r
-\r
/*\r
* Instructions for using this project are provided on:\r
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html\r
+ * TBD\r
*/\r
\r
- /* Miscellaneous initialisation including preparing the logging and seeding\r
- the random number generator. */\r
- prvMiscInitialisation();\r
-\r
- /* Initialise the network interface.\r
+ /* Create the example that demonstrates task pool functionality. Examples\r
+ that demonstrate networking connectivity will be added in future projects\r
+ and get started after the network has connected (from within the\r
+ vApplicationIPNetworkEventHook() function).*/\r
+ vStartSimpleTaskPoolDemo();\r
\r
- ***NOTE*** Tasks that use the network are created in the network event hook\r
- when the network is connected and ready for use (see the definition of\r
- vApplicationIPNetworkEventHook() below). The address values passed in here\r
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1\r
- but a DHCP server cannot be contacted. */\r
- FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );\r
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );\r
-\r
- /* Start the RTOS scheduler. */\r
- FreeRTOS_debug_printf( ("vTaskStartScheduler\n") );\r
+ /* Start the scheduler - if all is well from this point on only FreeRTOS\r
+ tasks will execute. */\r
vTaskStartScheduler();\r
\r
/* If all is well, the scheduler will now be running, and the following\r
really applicable to the Win32 simulator port). */\r
for( ;; )\r
{\r
- Sleep( ulLongTime_ms );\r
+ __debugbreak();\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
-void vApplicationIdleHook( void )\r
-{\r
-const uint32_t ulMSToSleep = 1;\r
-\r
- /* This is just a trivial example of an idle hook. It is called on each\r
- cycle of the idle task if configUSE_IDLE_HOOK is set to 1 in\r
- FreeRTOSConfig.h. It must *NOT* attempt to block. In this case the\r
- idle task just sleeps to lower the CPU usage. */\r
- Sleep( ulMSToSleep );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
void vAssertCalled( const char *pcFile, uint32_t ulLine )\r
{\r
-const uint32_t ulLongSleep = 1000UL;\r
volatile uint32_t ulBlockVariable = 0UL;\r
volatile char *pcFileName = ( volatile char * ) pcFile;\r
volatile uint32_t ulLineNumber = ulLine;\r
( void ) pcFileName;\r
( void ) ulLineNumber;\r
\r
- FreeRTOS_debug_printf( ( "vAssertCalled( %s, %ld\n", pcFile, ulLine ) );\r
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );\r
\r
/* Setting ulBlockVariable to a non-zero value in the debugger will allow\r
this function to be exited. */\r
{\r
while( ulBlockVariable == 0UL )\r
{\r
- Sleep( ulLongSleep );\r
+ __debugbreak();\r
}\r
}\r
taskENABLE_INTERRUPTS();\r
events are only received if implemented in the MAC driver. */\r
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )\r
{\r
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;\r
-char cBuffer[ 16 ];\r
-static BaseType_t xTasksAlreadyCreated = pdFALSE;\r
-\r
- /* If the network has just come up...*/\r
- if( eNetworkEvent == eNetworkUp )\r
- {\r
- /* Create the tasks that use the IP stack if they have not already been\r
- created. */\r
- if( xTasksAlreadyCreated == pdFALSE )\r
- {\r
- /* See the comments above the definitions of these pre-processor\r
- macros at the top of this file for a description of the individual\r
- demo tasks. */\r
- #if( mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS == 1 )\r
- {\r
- vStartSimpleUDPClientServerTasks( configMINIMAL_STACK_SIZE, mainSIMPLE_UDP_CLIENT_SERVER_PORT, mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY );\r
- }\r
- #endif /* mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS */\r
-\r
- #if( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )\r
- {\r
- vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );\r
- }\r
- #endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */\r
-\r
- #if( mainCREATE_TCP_ECHO_SERVER_TASK == 1 )\r
- {\r
- vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY );\r
- }\r
- #endif\r
-\r
- xTasksAlreadyCreated = pdTRUE;\r
- }\r
-\r
- /* Print out the network configuration, which may have come from a DHCP\r
- server. */\r
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );\r
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );\r
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );\r
-\r
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );\r
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );\r
-\r
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );\r
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );\r
-\r
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );\r
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationMallocFailedHook( void )\r
-{\r
- /* Called if a call to pvPortMalloc() fails because there is insufficient\r
- free memory available in the FreeRTOS heap. pvPortMalloc() is called\r
- internally by FreeRTOS API functions that create tasks, queues, software\r
- timers, and semaphores. The size of the FreeRTOS heap is set by the\r
- configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */\r
- vAssertCalled( __FILE__, __LINE__ );\r
+ /* This example is the first in a sequence that adds IoT functionality into\r
+ an existing TCP/IP project. In this first project the TCP/IP stack is not\r
+ actually used, but it is still built, which requires this function to be\r
+ present. For now this function does not need to do anything, so just ensure\r
+ the unused parameters don't cause compiler warnings and that calls to this\r
+ function are trapped by the debugger. */\r
+ __debugbreak();\r
+ ( void ) eNetworkEvent;\r
}\r
/*-----------------------------------------------------------*/\r
\r
-UBaseType_t uxRand( void )\r
-{\r
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;\r
-\r
- /* Utility function to generate a pseudo random number. */\r
-\r
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;\r
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvSRand( UBaseType_t ulSeed )\r
-{\r
- /* Utility function to seed the pseudo random number generator. */\r
- ulNextRand = ulSeed;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvMiscInitialisation( void )\r
-{\r
-time_t xTimeNow;\r
-uint32_t ulLoggingIPAddress;\r
-\r
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );\r
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );\r
-\r
- /* Seed the random number generator. */\r
- time( &xTimeNow );\r
- FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );\r
- prvSRand( ( uint32_t ) xTimeNow );\r
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#if( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )\r
-\r
- const char *pcApplicationHostnameHook( void )\r
- {\r
- /* Assign the name "FreeRTOS" to this network node. This function will\r
- be called during the DHCP: the machine will be registered with an IP\r
- address plus this name. */\r
- return mainHOST_NAME;\r
- }\r
-\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )\r
-\r
- BaseType_t xApplicationDNSQueryHook( const char *pcName )\r
- {\r
- BaseType_t xReturn;\r
-\r
- /* Determine if a name lookup is for this node. Two names are given\r
- to this node: that returned by pcApplicationHostnameHook() and that set\r
- by mainDEVICE_NICK_NAME. */\r
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )\r
- {\r
- xReturn = pdPASS;\r
- }\r
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )\r
- {\r
- xReturn = pdPASS;\r
- }\r
- else\r
- {\r
- xReturn = pdFAIL;\r
- }\r
-\r
- return xReturn;\r
- }\r
-\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-/*\r
- * Callback that provides the inputs necessary to generate a randomized TCP\r
- * Initial Sequence Number per RFC 6528. THIS IS ONLY A DUMMY IMPLEMENTATION\r
- * THAT RETURNS A PSEUDO RANDOM NUMBER SO IS NOT INTENDED FOR USE IN PRODUCTION\r
- * SYSTEMS.\r
- */\r
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,\r
uint16_t usSourcePort,\r
uint32_t ulDestinationAddress,\r
uint16_t usDestinationPort )\r
{\r
+ /* This example is the first in a sequence that adds IoT functionality into\r
+ an existing TCP/IP project. In this first project the TCP/IP stack is not\r
+ actually used, but it is still built, which requires this function to be\r
+ present. For now this function does not need to do anything, so just ensure\r
+ the unused parameters don't cause compiler warnings and that calls to this\r
+ function are trapped by the debugger. */\r
( void ) ulSourceAddress;\r
( void ) usSourcePort;\r
( void ) ulDestinationAddress;\r
( void ) usDestinationPort;\r
+ __debugbreak();\r
+ return 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
\r
- return uxRand();\r
+UBaseType_t uxRand( void )\r
+{\r
+ /* This example is the first in a sequence that adds IoT functionality into\r
+ an existing TCP/IP project. In this first project the TCP/IP stack is not\r
+ actually used, but it is still built, which requires this function to be\r
+ present. For now this function does not need to do anything, so just ensure\r
+ the calls to the function are trapped by the debugger. */\r
+ __debugbreak();\r
+ return 0;\r
}\r
/*-----------------------------------------------------------*/\r
\r