Quality RTOS & Embedded Software

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




Loading

Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

I apologize in advance if this question has been posted. If so, could you please post a link as I searched and could not find what I am looking for.

Very basic: I've set a up a message queue with 3 elements of uint8. I've declared the queue handle and the "pvItemToQueue" globally so I could call it from another module/function. In that function I use "extern" to declare the 2 variables.

When I send to the message queue from withing the module where it's defined (in main.c) the rx queue seems to function OK. When I try to send a message from the other module (& function) the message never seems to show up in the rx queue.

One thing to note: the function where the queue is (seemingly) not working is called in a Timer ISR. Not sure if this has any significance - I realize that there's a different call for ISR's. I changed the call to the ISR queue send, but it did not appear to work either.

Thanks for any help you can provide!


Sending a Queue message from a function - never gets there?

Posted by rtel on April 30, 2015

Please post a snippet of code that shows how the queue handle is declared and used in the separate module (the one that is not working). Please also say which port you are using (makes a difference as to how helpful configASSERT() would be in finding the problem).

Regards.


Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

Hello, Thank you your response. I am using v8.2.0

Here is the code below from function that doesn't seem to send message. Also tried sendtoback, and sendtofront.

extern QueueHandlet eventQueue; extern uint8t mssgEvent;

//in header file is this define: //#define rxQueueRATE ( ( TickTypet ) 50 / portTICKPERIODMS )

void myFunc(void) { ...do some stuff

mssgEvent = 4;
xQueueSend( eventQueue, &mssgEvent, rxQueue_RATE );            

....more stuff..

}


Sending a Queue message from a function - never gets there?

Posted by rtel on April 30, 2015

Presumably the queue has been created.

What does the call to xQueueSend() return? It should be pdTRUE (success) or pdFALSE (timed out).


Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

It does not print either of these...but it is not hanging the system up either, as the FreeRTOS is also kicking the WDT.

mssgEvent = 1;

if( xQueueSend( eventQueue, ( void * ) &mssgEvent, ( TickType_t ) 50 ) != pdPASS ) printf("Could not queue event mssg 1n"); else printf("Message 1 queuedn");


Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

Another bizarre bit.

I also perform a send to queue in the main function where the queue is declared and the function handler is. There is no issue sending to the queue from main. However, from the other module/function, when I try to send to queue from there (as shown in the above post) it actually seems to inhibit (block?) the send to queue in main from functioning. When I comment out the xQueueSend (in the last post) the call to xQueueSend in main can be seen by the response in the handler.

I'm still trying to understand how it could get by this without printing anything

if( xQueueSend( eventQueue, ( void * ) &mssgEvent, ( TickType_t ) 50 ) != pdPASS ) printf("Could not queue event mssg 1n"); else printf("Message 1 queuedn");

...when there are debug print statements before and after (for other things) that work.


Sending a Queue message from a function - never gets there?

Posted by edwards3 on April 30, 2015

It does not print either of these.

There are only two paths through there. If its not printing either then it can mean one of two things, either the code is not being run or your printf function is not working.

I also perform a send to queue in the main function

Before calling vTaskStartScheduler()? Probably not a good thing to do.


Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

You're assuming I call xQueueSend before launching the scheduler? Why would I do that?

Let's assume the printf works for the reason I indicated, that I have printf's before and after to clarify oto the reader that printf does work properly. There's no issue with printf running anywhere on this controller.

That leaves: " the code is not being run.."

Why would it not run? All header files are included... Suggestions as to what I could try next are welcome.


Sending a Queue message from a function - never gets there?

Posted by edwards3 on April 30, 2015

You're assuming I call xQueueSend before launching the scheduler?

Wasnt assuming, you implied it "I also perform a send to queue in the main function" main() doesnt run after the scheduler has been started, only before.

Why would it not run?

I dont know, I can only see a fragment of your code, but as you say printf() is working, and as there are no paths through the code that dont print something but nothing is printing, logic says the code is not being run. You can find out easily by putting a break point on the queue send. If the break point is hit then the code is being run, and you can step through the source in the debugger to see why the print never prints.


Sending a Queue message from a function - never gets there?

Posted by groger57 on April 30, 2015

I was only asked to post the code that I did. I can post it all, but I don't see how this is that complex. I create the queue, declare the function, launch the scheduler, run the send queue from the main module, and it works. I try to run the send queue from the other module, and it not only not works there, it stops the one in the main module from running.

In the other module, I set the code to this: xQueueSendToFront( eventQueue, &mssgEvent, rxQueue_RATE );

No printf after, just variable assignments. I put a breakpoint on one of those variable assignments. It never reaches anything after. Like it beams up, without hanging up the system. Again, if I comment this out - in the external module function - the call xQueueSend in the function in the "main module" runs OK, the receive handler/function gets the message.


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS