heinbali01 wrote on Thursday, June 05, 2014:
Hi Radoslav,
Question 2: about C++ and embedded:
It is very well possible to use FreeRTOS in combination with C++ !
Personally I find C++ easier to read and it gives some more safety, more protection against making stupid mistakes.
There is an implementation of C++ and FreeRTOS: http://www.stf12.org/developers/FreeRTOS_EC.html
I didn’t try it myself, but several people on this list liked it.
FreeRTOS_EC imposed the same limitations as I also do for embedded:
- No use of the Template Library (STL)
- No Run Time Type Information (RTTI)
- No C++ Exception handling (-fno-exceptions)
So it’s just C++, but I do use the powerfull C++ templates.
Using C++ is more expensive. For writing a small bootloader, I will use plain C.
Be sure to get the correct linking: C versus C++. I thing all FreeRTOS headers now have:
#ifdef __cplusplus
extern "C" {
#endif
/* declarations */
#ifdef __cplusplus
} /* extern "C" */
#endif
Question 1:
If I may translate: It is safe to use a dynamically allocated variable that holds pointers to system handles?
Can you describe how your queueHandle is created?
Somewhere you declare the identifier ‘queueHandle’, what does it look like?
The following would be no problem:
struct MyHandles {
SemaphoreHandle_t xSemaphore;
QueueHandle_t xQueue;
TaskHandle_t xTask;
};
int main ()
{
struct MyHandles *myHandles;
myHandles = ( struct MyHandles* ) pvPortMalloc( sizeof *myHandles );
if( myHandles )
{
memset( myHandles, '\0', sizeof *myHandles );
myHandles->xQueue = xQueueCreate( QUEUE_LENGTH, QUEUE_SIZE );
}
}
In this example ‘myHandles’ is a local variable, pointing to a set of system handles. As long as ‘myHandles’ isn’t deleted, you can use all members.
Regards,
Hein