I changed the demo project of FreeRTOS and i can get only first element of struct.
> void main_blinky( void )
> {
>
> printf( "\r\nStarting the blinky demo. Press \'%c\' to reset the software timer used in this demo.\r\n\r\n", mainRESET_TIMER_KEY );
>
> /* Create the queue. */
> xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );
>
> if( xQueue != NULL )
> {
> /* Start the two tasks as described in the comments at the top of this
> file. */
> xTaskCreate( prvQueueReceiveTask,
> "Rx",
> configMINIMAL_STACK_SIZE,
> NULL,
> mainQUEUE_RECEIVE_TASK_PRIORITY,
> NULL );
>
> xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
>
>
>
>
> vTaskStartScheduler();
> }
>
> for( ;; );
> }
> /-----------------------------------------------------------/
>
> typedef struct {
> int initialPosition[2]; // x and y coordinates
> int velocity[2]; // V_x and V_y components
> float gaussianNoise[2]; // O_x and O_y components
> } Measurments;
>
> static void prvQueueSendTask( void *pvParameters )
> {
> TickType_t xNextWakeTime;
> const TickType_t xBlockTime = mainTASK_SEND_FREQUENCY_MS;
>
> Measurments data;
>
> ( void ) pvParameters;
>
> xNextWakeTime = xTaskGetTickCount();
>
>
> for( ;; )
> {
>
> data.initialPosition[0] = 10; // Example: x coordinate
> data.initialPosition[1] = 30; // Example: y coordinate
> data.velocity[0] = 5; // Example: V_x
> data.velocity[1] = 2; // Example: V_y
> data.gaussianNoise[0] = 0.1f; // Example: O_x
> data.gaussianNoise[1] = 0.2f; // Example: O_y
>
> vTaskDelayUntil( &xNextWakeTime, xBlockTime );
>
>
> xQueueSend( xQueue, &data, 0U );
>
> }
> }
>
>
> static void prvQueueReceiveTask( void *pvParameters )
> {
> uint32_t ulReceivedValue;
>
> Measurments receivedData;
>
> ( void ) pvParameters;
>
> for( ;; )
> {
> xQueueReceive( xQueue, &receivedData, portMAX_DELAY );
>
> taskENTER_CRITICAL();
> {
>
>
> printf("Received Data:\r\n");
> printf("Initial Position: x=%d, y=%d\r\n", receivedData.initialPosition[0], receivedData.initialPosition[1]);
> printf("Velocity: V_x=%d, V_y=%d\r\n", receivedData.velocity[0], receivedData.velocity[1]);
> printf("Gaussian Noise: O_x=%f, O_y=%f\r\n", receivedData.gaussianNoise[0], receivedData.gaussianNoise[1]);
>
>
>
> }
> taskEXIT_CRITICAL();
> }
> }
Output:
Received Data:
Initial Position: x=10, y=-858993460
Velocity: V_x=-858993460, V_y=-858993460
Gaussian Noise: O_x=-107374176.000000, O_y=-107374176.000000