FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2009 Threads] xQueueReceive with structuresPosted 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 structuresPosted 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 structuresPosted 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 structuresPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|