Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

xQueueReceive with structures

Posted by echel0n on February 18, 2009
Ok what I'm trying to do is send data from my uart to another task that will send it out via ethernet.
Problem is when I transfer the data and length variables it seems to only send and store one of the values.

Any idea's on how I can accomplish or fix this code ?

Here's some of the code I have so far:

typedef struct
{
long length;
signed char *data;
} xIKSMessage;

// Task 1
/* The queue used to send data to the IKS task. */
xQueueHandle xIKSQueue;

void task1(void)
{
xIKSMessage xMessage;

xIKSQueue = xQueueCreate( 10, sizeof( struct xIKSMessage * ) );

// Wait for RX Data from receiver
while ((uart1in.length = uart1Read(uart1in.data)) == pdFALSE);

// Send data to IKS Server
xMessage.length = uart1in.length;
xMessage.data = uart1in.data;

/* Send the message to the LCD gatekeeper for display. */
xQueueSend( xIKSQueue, &xMessage, portMAX_DELAY );
}

// Task2
/* The queue used to send data to the IKS task. */
xQueueHandle xIKSQueue;

void iks_appcall(void)
{
xIKSMessage xData;

if( xIKSQueue != 0 )
{
// Receive a message on the created queue. Block for 10 ticks if a
// message is not immediately available.
if( xQueueReceive( xIKSQueue, &xData, ( portTickType ) 10 ) )
{
if(uip_connected() || uip_rexmit())
{
uip_send(xData.data, xData.length);
iks_datasent = 1;
}
}
}
}

RE: xQueueReceive with structures

Posted by Richard Damon on February 18, 2009
You are defining your queue to hold a "struct xIKSMessage *", but are sending it a "struct xIKSMessage".

Your queue should be sized to hold "struct xIKSMessage"


RE: xQueueReceive with structures

Posted by echel0n on February 18, 2009
Ok I was able to get it working fine but now I'm having issues with xQueueSend ....
I'm trying to send a char array and it seems as if only the first byte gets sent and the rest of the data never makes it.

RE: xQueueReceive with structures

Posted by Adam Turowski on February 18, 2009
The queque copies to internal queque structures the data you provide it as an input . So to send structures or tables, you should create queque that has elements size equal to of structure/table size NOT size of pointers to structure/table.

When you attempt to send something, queue Send function copies the amount of bytes (usually) declared as element size during queue creation. It copies this amount of bytes from buffer pointer provided as Send function input argument.
If you declared queue element of size of pointer, it will send only amount of bytes equal to pointer size in bytes each time you call Send function.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists