Ah, yes, I see the problem.
There is no way that I will abandon C++, have too much code written in it, and for a graphics system, well, inheritance of objects makes too much sense.
The C++ wrappers around FreeRTOS functions that I used made use of the constructors to establish parameters, and indeed, called parts of the class to make things work.
While FreeRTOS (in ST micro land) has the ability in their IDE to set up tasks, I don’t do that. There is only one task at the very beginning, and that’s the default FreeRTOS task as implemented by the IDE. From that task, I call a bridge setup task which is designed to be called from C. That task then initializes the I2C, SPI, and Serial drivers as well as installs a display. The initializations are solely controlled by #define and #ifdef in a configuration file. So far, that configuration file (with suitable adjustments) is used for all projects.
So everything is installed programatically. Since there are no default C++ tasks, the approach using the constructors to initialize and set up a FreeRTOS task under C++, while very nice, simply didn’t meet the programming model I use.
Since the constructors assume an existing task before they’re called, as I program the project, the code is not real, pointers to it are null.
And given this model, constructors can’t be used. I do use a “new” to reserve space for the class, then there’s a create (which sets up structures), and an init (which sets up parameters and is often parametrically driven). So this is close to what you do.
At this point, statically and dynamically created objects do not seem to be important.
What the problem is, and you’ve solved it in your code, is that tasks run immediately upon creation. Some tasks are interdependent, they require facilities that may not yet exist. My request would be to be able to create a non-running task, and simply start it up when needed. My current solution is to create a task with priority 0, then immediately suspend it (creation tasks and most others are at about 3). This works for me, since I don’t use SMP, nor the processors that use it. Love to, but either cost or package limitations seem to get in the way.
What I wanted was a method to simplify the problem, which would simply be to create a non-running task. An operating system I wrote for the Xmega allowed just that.
And what I wanted FreeRTOS to do was to define an arbitrary modification to the creation method to create a non-running task.
You’re not missing much except the context in which this happens. A number of projects pulling from a common group of programs, which are configured by a single configuration file per program.
I might consider a slightly different mechanism.
- each task knows what it is dependent on.
- if the task does not exist, then the dependent task is in a wait loop.
- if it does exist, then check a “running” variable in the task, which if set, allows the dependent task to run.
- e.g. NRF mesh networking needs the packet system running, so there’s a check.
- remote registry and device finding (such as remote displays) needs both the NRF mesh network running and valid entries in the DHCP table.
- so dependencies…
I like the idea of automating things.
Thanks