Closed vChavezB closed 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
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:
I have added a new port that supports UC-OS-III.
Changes
OS_CPU
macros in version 3 have changed to the prefixCPU_
instead.QP::QActive
. This is due to the fact that UC-OS now has an internal queue per task which can be enabled/disabled viaOS_CFG_TASK_Q_EN
.m_thread
is of typeOS_TCB*
since creating a task now needs a Task control block.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.