QuantumLeaps / qpcpp

QP/C++ Real-Time Embedded Framework/RTOS for embedded systems based on active objects (actors) and hierarchical state machines
https://www.state-machine.com/products/qp
371 stars 82 forks source link

Added ucos-iii port with an Arduino example #13

Closed vChavezB closed 2 years ago

vChavezB commented 2 years ago

I have added a new port that supports UC-OS-III.

Changes

How to test

I have added an example for the uc-os-iii port in examples/ucos-iii/ArduinoDue-qpcpp-ucos-iii. The example requires the Arduino SDK and a UCOS-3 port for Arduino that I released some time ago. In addition, I modified the QP Arduino repository to make it compatible with the QP CPP uc-os-ii port.

The example creates a task that posts a signal periodically. This signal is consumed by a QP::QActive and prints through the serial port when it enters a new state and makes a transition. I think the uc-os-ii examples could be ported but version 3 but need refactoring due to the API change between v2 and v3. The example I provide can serve as a reference of what needs to be changed for UC-OS v3.

quantum-leaps commented 2 years ago

The UCOS-3 port as it currently stands is probably incorrect. The "uC/OS-III event queue and thread types" configured in qf_port.hpp should most likely be whole types OS_Q and OS_TCB instead of pointers. Consistently with that change, the qf_port.cpp needs to be modified and the static OS_TCB task_tcb and static OS_Q os_q need to be removed. Static objects like that are an obvious mismatch as to multiplicity of the required objects. You need separate OS_TCB/OS_Q objects per task and NOT one static instance per all of them.

I will try to review the port further, but these are just the main "red flags" that I noticed.

--MMS

vChavezB commented 2 years ago

Oh yes, my bad about the static declaration!

About the type of data types being whole types. How would the user pass the extra parameters that are needed for the Task (name and stack options) when they can no longer pass data through pointers? I see that the OS_TCB struct has pointer-type members so they could be used instead for example in QActive::setAttr()

Just some additional comments on the changes I made: