3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
29 * Manages a queue of strings that are waiting to be displayed. This is used to
30 * ensure mutual exclusion of console output.
32 * A task wishing to display a message will call vPrintDisplayMessage (), with a
33 * pointer to the string as the parameter. The pointer is posted onto the
36 * The task spawned in main. c blocks on xPrintQueue. When a message becomes
37 * available it calls pcPrintGetNextMessage () to obtain a pointer to the next
38 * string, then uses the functions defined in the portable layer FileIO. c to
39 * display the message.
42 * Using console IO can disrupt real time performance - depending on the port.
43 * Standard C IO routines are not designed for real time applications. While
44 * standard IO is useful for demonstration and debugging an alternative method
45 * should be used if you actually require console IO as part of your application.
47 * \page PrintC print.c
55 + Delay periods are now specified using variables and constants of
56 + TickType_t rather than unsigned long.
61 /* Scheduler include files. */
65 /* Demo program include files. */
68 static QueueHandle_t xPrintQueue;
70 /*-----------------------------------------------------------*/
72 void vPrintInitialise( void )
74 const unsigned portBASE_TYPE uxQueueSize = 20;
76 /* Create the queue on which errors will be reported. */
77 xPrintQueue = xQueueCreate( uxQueueSize, ( unsigned portBASE_TYPE ) sizeof( char * ) );
79 /*-----------------------------------------------------------*/
81 void vPrintDisplayMessage( const char * const * ppcMessageToSend )
84 xQueueSend( xPrintQueue, ( void * ) ppcMessageToSend, ( TickType_t ) 0 );
87 ( void ) ppcMessageToSend;
90 /*-----------------------------------------------------------*/
92 const char * pcPrintGetNextMessage( TickType_t xPrintRate )
96 if( xQueueReceive( xPrintQueue, &pcMessage, xPrintRate ) == pdPASS )