Quality RTOS & Embedded Software

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




Loading

is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on May 22, 2014

Hello,

I found this FreeRTOS Extension Class : http://www.stf12.org/developers/FreeRTOS_EC.html but I don't know if it's reliable and I will be able to adpat this with the latest version of FreeRTOS and making it work with a PIC32, is there any people who have already test it ?

Thanks in advance (and sorry for bad english)


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on May 23, 2014

Yes, this FreeRTOS Extension Class : http://www.stf12.org/developers/FreeRTOS_EC.html works like a charm, I managed to make it work with a PIC32, in fact, the original programmer used a STM32, it's a good C++ over-layer for FreeRTOS !


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on May 26, 2014

Hi all,

the FreeRTOS Extension Class was designed as wrapper classes for the FreeRTOS native handles. My work on that component is frozen to FreeRTOS v7.0.0 (because I'm working on other projects :-). To update the class library to the last version of FreeRTOS you need: - to add the new FreeRTOS API to the corresponding class object - to add new class derived by the IFreeRTOSObj in order to wrap the new FreeRTOS native handle. - take into account the new name convention.

Let me know if you need more information.

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on May 27, 2014

Hi Stefano,

I want to thank you for you awesome work.

If I have problems or questions, do you have a dedicated forum for your class extension layer or can I send you a personal message ?


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by rtel on May 27, 2014

If your questions are FreeRTOS related (as opposed to pure C++ questions that are unconnected to the FreeRTOS framework), and if Stafano does not have his own forum, I would prefer to keep the thread on this forum so other FreeRTOS users who have similar questions in the future will be able to see the conversation.

Regards.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on May 27, 2014

Hi,

thanks to the FreeRTOS team to provide us this forum to discuss about FreeRTOS and the Extension class.

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on May 29, 2014

Hi, I'm working to update the FreeRTOS_EC in order to support FreeRTOS 8. A first minor update is ready: I have refactored the source code to support the new FreeRTOS Defined typedefs Names. The next step is to provide C++ support for the new features of FreeRTOS 8.

I made also a demo to show how it works. Following are the main features of the demo: - target platform: STM324x9I-Eval evaluation board (STM32F439 Cortex-M4 MCU) - toolset: GNU Tools for ARM Embedded Processors - Some of the standard FreeRTOS demo tasks re-implemented as C++ class (BlockQ, Integer, PollQ, SemTest) - target specific tasks (Led, LCD, Timer)

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on May 30, 2014

Excellent ! thank you very much Stefano !


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on June 2, 2014

Hello Stefano,

Can you tell me please what does the prefix "A" mean in AManagedTask and "I" in IFreeRTOSObj, for "C" I think the prefix means Class

I hope that the new version will be released soon.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on June 3, 2014

Hi,

A = Abstract. It identifies a class with some pure virtual methods. This means that the class is partially implemented, and a subclass must provide a its own implementation of that methods.

I = Interface. This class has only pure virtual methods. It specifies a "contract" between objects.

I will provide a link to download the asap in this forum. If you want to give a look, and help me to test it... ;-) ... you can download the source from the SVN repository:

http://code.google.com/p/stf12/source/browse/#svn%2Ftrunk%2FFreeRTOSECDemoSTM324x9I-EVAL

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on June 3, 2014

Thank you / grazie !


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on June 5, 2014

Hi,

I would like to give you a quick update. I have committed a new version of the FreeRTOS_EC class in the repository. Following is the status:

  • Added CQueueSet class.
    • Need to redefine how the functions that return a resource handle are managed: I want to return an object reference, but I don't want to dynamically allocate the object.
    • Possible solution is for example : QueueSetMemberHandlet xQueueSelectFromSet( QueueSetHandlet xQueueSet, const TickTypet xTicksToWait ) CSetMember &CQueueSet::SelectFromSet(const TickTypet xTicksToWait, &CSetMember)
  • New supported FreeRTOS API (FreeRTOS_EC related class)
    • xSemaphoreGetMutexHolder (ASyncObject)
    • xTimerGetTimerDaemonTaskHandle (ATimer)
    • xTimerPendFunctionCall (ATimer)
    • xTimerPendFunctionCallFromISR (ATimer)
    • vTaskStepTick (CFreeRTOS)
    • uxQueueMessagesWaitingFromISR (CQueue)
    • uxQueueSpacesAvailable (CQueue)
    • xQueueReset (CQueue)
    • xQueueOverwrite (CQueue)
    • xQueueOverwriteFromISR (CQueue)
    • xQueuePeekFromISR (CQueue)
    • vQueueUnregisterQueue (CQueue)
    • xQueueIsQueueFullFromISR (CQueue)
    • xQueueIsQueueEmptyFromISR (CQueue)
    • uxTaskGetSystemState (CTask)
    • xTaskGetApplicationTaskTag (CTask)
    • xTaskGetIdleTaskHandle (CTask)
    • uxTaskGetStackHighWaterMark (CTask)
    • eTaskGetState (CTask)
    • pcTaskGetTaskName (CTask)
    • xTaskGetTickCountFromISR (CTask)
    • vTaskSetApplicationTaskTag (CTask)
  • Not supported API:
    • Event Group
    • What about the MPU support? Need to test

Regards, Stefano

NOTE: the demo project has been developed using Eclipse (IDE) + GNU ARM Eclipse Plug-ins + GNU Tools for ARM Embedded Processors (Toolset)


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on June 5, 2014

Awesome ! Thank you very much once again ! I ll test the updated extension class very soon.

As I'm a PIC32 user, I want to ask you a question about using the STM32 with eclipse and the GNU ARM solution, does the 32KB code size limitation disappear with that solution ? because I might one day try and work with the STM32, apparently, it has interesting features that the PIC32 doesn't have.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on June 5, 2014

Hi,

ST32 is a great family of Cortex-M microcontrollers with amazing features! And... yes, you can program it without limitation. Give a look at this video: http://www.stf12.org/stm32ide/

I hope you can find it useful :-)

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by rtel on June 5, 2014

...and of course both PIC32 and STM32 have drivers/middleware integrations with FreeRTOS ;o)

http://www.microchip.com/harmony http://www.st.com/stm32cube

Regards.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by jradoslav on June 5, 2014

Dear Stefano thanks for FreeRtos EC class, but can you explain that C++ binary generation is good for ARM unit with 40Mhz, 32KB RAM or any microECU at all? because our c++ tests produce huge binary(30kb C vs 250Kb C++ bin) with very bad optimalized procedures and functions, that I think its dangerous to use C++ compiler in our project in microECU. C++ is very good language but its compiler/linker has more problems: http://warp.povusers.org/grrr/cplusplusvsc.html


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on June 10, 2014

Dear Radoslav,

thanks to open this discussion. I'm pleasure to share with you and this forum my thinking about the evolution of embedded application, but I don't want to convince anyone because I'm not a GURU. :-)

A "small" MCU (40 Mhz and 32KB RAM) designed for application that are small in term of code lines, is not a good choice to push the OO evolution in the embedded world

When I designed the FreeRTOS_EC classes I have had in mind the evolution we saw a lot of years ego in the PC world: more powerful CPU => complex and bigger (in term of code lines) applications => new programming paradigm to manage this complexity. For this reason we saw the evolution the programming languages from Assembler to procedural languages (C) to functional and object orient language (C++), and so on.

Are we in time to introduce C++ in the embedded world? I think of yes if I look to application like the smart brand or the internet of things. A Cortex-M MCU today is powerful enough to manage a complex multitouch application. So it is time to design in a different way the application.

For sure we need to learn how fine tune the g++ compiler for an embedded application.For example in term of code size is it possible: - to remove the exception handler feature - to remove RTTI feature - to remove the portion of the runtime that manage the execution of static and global object distractor

It could be interesting to make some test between C and C++ code using some well defined code samples (may be a standard FreeRTOS demo implemented in both way). What do you think?

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on June 10, 2014

what are you saying is very interesting and useful ! Thank you !


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on June 16, 2014

Hi all,

just a quick update: - Modified the CQueueSet class. - Added a standard demo task. See CQueueSetTes class.

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by jradoslav on June 17, 2014

Hi Stefano

I understand what you're saying but I think that if hardware or digital world will work on TWO state value - control and data follow streams, state machines and extended SM. Until then will exist computer languages like ASM higher C and their coders, because computer language is derived from real HW architecture.

So,technologies ( C ASM and HW ) is tool or provider for OOP evolution. Rather Operation systems designed under C for specific HW is good provider for OOP abstraction and its interpretation.

Therefore i think that OOP evolution can be pushed directly to small embeded world, but this question not solve porting C to C++ of Freertos code.

This problem solve design of theroy or converting method from higher OOP languages(Java,C#,rubby etc) or UML model directly to C code generation. next this generated C code can be compiled with Freertos kernel code. And this is not easy work.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on July 30, 2014

Hello Stefano,

Under a PIC32MX, with your framework (version 7, the old one) I created 4 Tasks with different priorities (ADC,FFT,UART, and LED) and I used mutexes (from the framework of course) to synchronize between them.

I noticed something odd : when mutexes or the array used by those tasks are global and static my application don't work and I don't know why ??? that's very strange since they are static variables.

So I am obliged to give to my tasks pointers to the mutexes and the data (arrays to store the collected ADC sample and FFT results) so everything works very well.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on August 1, 2014

Hi,

this is strange. I have attached a simple demo (4 tasks and 2 mutex) that works fine. Is the test like your application?

Regards, Stefano

Attachments

sample.zip (5973 bytes)

is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on August 2, 2014

Hello,

it's strange but it's microchip stupid compiler, the problem touchs not only synchronization mechanisms (semaphores mutexes ...) but all normal variables (arrays etc...)

I will give you an example : when I fill a STATIC array with data in "FFT TASK" the UART TASK sends to the computer zeros, so in fact, the FFT TASKS doesnt fill the static array but it's filling another thing I don't know really which one, that's really odd) and this is the compiler fault !

if the array contains zeros, it means that it has not been filled, but when I give to the FFT task or any normal task a pointer the array or the variable to modify, in fact, it works !

I want to say a message to those who want to use your work under MPLABX (Microchip PIC32) yesterday I had many problems with interrupts, I spend hours to find the solution, so you can compile : you must use extern "C" with the functions that will be ISRs and not in the prototype of the ISRs wrapper as commonly known, this is for the compilation.

if the interrupt level of the interrupt source (e.g. timer) which you have put in its IRQ register is higher than the level you have put in the ISR wrapper prototype (the iplx argument where x is a number between 1 and 7) your application will crash (you will have this ugly message in debug mode console : No source code lines were found at current PC ....)

Stefano, the hardware initialization method with a task crashed my application so when I put instructions that perform dynamic allocation inside the constructor instead of that method, my application didn't crash, but I noticed this problem with only one task... so I avoid using this method.

I think that all those problems come from the LAME microchip XC32++ compiler, if you dont know : optimization are not available for the free version of XC32++, this is really a joke, if the compiler doesnt't do the optimization work, who will do it ??? Microchip is a tightwad company, you will notice that also in their dev kits ;) I'm glad I started working with the STM32.

Stefano, did you know that in order to work with interrupts under FreeRTOS and PIC32 we must use assembly wrappers (a single .S file for each ISR inside we must put the name of the C written ISR) ? does this exist also with the STM32 ? I started working with the STM32F4 and I don't know how ISR's are managed under this ARM based mcu and its FreeRTOS port, I hope that you can give a fast answer to my question before I start searching the information and Thank you in advance.

I ll look at the example you gave me, but I know that's unuseful since it's the compiler fault, I must avoid using static variables inside the tasks, the program will compile but it will not run as expected because the Microchip is not reliable when compiling C++ projects.

In debug mode I can't even browse the insctructions !!!

To conclude, your work works under PIC32 but tasks must use pointers to the mutexes, semaphores, queues or even arrays or simple variables... otherwise the application will not work, in debug mode, in the IDE console we can read : "No source code lines were found at current PC 0x........"

if my advices concerning interruptions are not respected you will have the same message, avoid also to use HardwareInitalize and put your hardware initialization in the constructor.

Thank you and sorry for bad english.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on August 4, 2014

Well, LOL, with another example that I made, the static variables worked inside the tasks !

Maybe I had a little bug in my precedent examples or maybe it's the compiler fault, I dont know, it's hard to investigate problems under an RTOS.

But I ll still say that MPLAB X and its comiler sucks hard !


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by stf12 on August 5, 2014

Hi,

let me share my experience about what I know. I have never worked with a PIC32 MCU.

About the interrupt problem:

you must use extern "C" with the functions that will be ISRs and not in the prototype of the ISRs wrapper as commonly known, this is for the compilation.

you must use the extern "C" in order to make a function-name in C++ have 'C' linkage.

~~~~~~ // Individual C linkage declaration extern "C" void foo();

// Block C linkage declaration extern "C" { void MyFunc1(); void MyFunc2(int n); } ~~~~~~

This is, more or less, because since C++ has overloading of function names and C does not, the C++ compiler cannot just use the function name as a unique id to link to, so it mangles the name by adding information about the arguments.

About the interrupt management for STM32, a complete answer will be too long for a single post, but you can look at the sample code coming with the FreeRTOS distribution (there are a lot of STM32 demo) or with my C++ demo (CIrqDrivenTask.cpp). With STM32 you can write your Interrupt Service Routine using a C function.

For the other issues, for example the one with the HardwareInit method, it would be better if you can share a code sample to analyze the problem.

Regards, Stefano


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by amineos1 on August 6, 2014

Okay thank you.


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by picwarrior on December 28, 2015

Bonjour Aminos,

Je m'intéresse à l'utilisation de FreeRTOS sur un PIC32MZ, en utilisant le C++. En C, j'arrive très bien à utiliser FreeRTOS, mais le projet que je suis en train d'essayer de porter maintenant en C++ avec FreeRTOS ne compile pas du tout, à cause de FreeRTOS. J'ai déjà passé une journée entière à investiguer ce problème, notamment sur les forum Microchip et de FreeRTOS, et il semblerait que la solution réside dans l'utilisation d'rapper pour freeRTOS tel que FreeRTOS Extension Class.

Vous êtes une des rares personnes sur les forums à utiliser FreeRTOS Extension Class sur un PIC, alors je me permets de vous contacter à ce sujet.

Vous serait-il éventuellement possible de partager un projet exemple montrant comment utiliser FreeRTOS Extension Class sur un PIC ? En retour, je pourrai vous faire bénéficier de mes résultats sur un PIC32MZ, si celà a de l'intérêt pour vous.

Ou bien, vous serait-il possible au moins de me conseiller sur la direction à explorer afin de réussir à compiler et faire tourner un projet en C++ en utilisant FreeRTOS sur un PIC32 ?

Bien cordialement,

PICwarrior


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by picwarrior on December 28, 2015

Bonjour Aminos,

Je m'intéresse à l'utilisation de FreeRTOS sur un PIC32MZ, en utilisant le C++. En C, j'arrive très bien à utiliser FreeRTOS, mais le projet que je suis en train d'essayer de porter maintenant en C++ avec FreeRTOS ne compile pas du tout, à cause de FreeRTOS. J'ai déjà passé une journée entière à investiguer ce problème, notamment sur les forum Microchip et de FreeRTOS, et il semblerait que la solution réside dans l'utilisation d'rapper pour freeRTOS tel que FreeRTOS Extension Class.

Vous êtes une des rares personnes sur les forums à utiliser FreeRTOS Extension Class sur un PIC, alors je me permets de vous contacter à ce sujet.

Vous serait-il éventuellement possible de partager un projet exemple montrant comment utiliser FreeRTOS Extension Class sur un PIC ? En retour, je pourrai vous faire bénéficier de mes résultats sur un PIC32MZ, si celà a de l'intérêt pour vous.

Ou bien, vous serait-il possible au moins de me conseiller sur la direction à explorer afin de réussir à compiler et faire tourner un projet en C++ en utilisant FreeRTOS sur un PIC32 ?

Bien cordialement,

PICwarrior


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by rtel on December 28, 2015

Generally, if you compile the FreeRTOS source code as C, and the application code as C++, then it should work ok. Other than that there are a few third party C++ wrappers for FreeRTOS, for example: http://interactive.freertos.org/entries/223648-Using-FreeRTOS-with-C-


is there an object-oriented C++ port of FreeRTOS or even an over-layer

Posted by richard_damon on December 29, 2015

I have put up my wrappers at https://github.com/richard-damon/FreeRTOScpp

It is a simple C++ wrapper for FreeRTOS.


[ 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