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

How to send string through queue

Posted by ephobb on December 27, 2015

Hi, This is my first FreeRTOS based project. I am trying to send string through one task to uart task. but i could see, only 1st letter is being sent. here is my code [code] gblqueuehandler = xQueueCreate(6,sizeof(uint8t)); xTaskCreate((TaskFunctiont)Sduart,"Suart",256,NULL,1,NULL); xTaskCreate((TaskFunctiont)send_str1,"string1",256,NULL,0,NULL);

void sendstr1(void const * argument) { uint8t dat[5]={'S','K','N','A','B'}; for(;;) { xQueueSend(gblqueuehandler,&dat[0],0); vTaskDelay(1000); } }

void Sduart(void const * argument) { uint8t data[6]={0}; uint8t da; for(;;) { HALUARTTransmit(&huart1,"UART Task",9,1000); if(xQueueReceive(gblqueuehandler,data,100)) { HALUARTTransmit(&huart1,&data[0],1,1000); } else { HALUART_Transmit(&huart1,"No Data",7,1000); } } }

[code]

and part of the output where i m receving queued data is "....UART TaskSUART...."


How to send string through queue

Posted by edwards3 on December 27, 2015

This line

xQueueCreate(6,sizeof(uint8_t));

creates a queue that holds 6 characters max. Each character is 8bits. http://www.freertos.org/a00116.html

This line

xQueueSend(gblqueuehandler,&dat[0],0);

sends ojne character to the queue. Only the 'S' is ever sent to the queue (the queue holds 8bit types).

If you want to send a string then the string needs to be null terminated in the normal C way, and then you need to create the queue to hold char pointers.

~~~~ /* Create a string that holds pointers, each pointer is 4 bytes. / xQueueCreate(6,sizeof(char));

const char *myString="SKNAB";

/* Queue a pointer. */ xQueueSend(gblqueuehandler,&myString,0); ~~~~


How to send string through queue

Posted by ephobb on December 27, 2015

Thanks it works. can you please give me some links for queue tutorial. I read basic queue creation, send and receive. but i want to know how to protect it with semaphore. because more than task may be send data to uart.


How to send string through queue

Posted by rtel on December 27, 2015

Queues (or any other FreeRTOS object) do not need to be protected by the application - that is all taken care of by the RTOS itself. Any number of tasks and interrupts can write to or read from the same queue. Note that when accessing a queue from an interrupt only the API functions appended with "FromISR" can be used.

Regards.


[ 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