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

QPCPP as external Zephyr module #18

Closed vChavezB closed 1 year ago

vChavezB commented 1 year ago

In this pull request you will find how qpcpp can be integrated as an external zephyr module.

I tested the changes with the Dining Philosophers Problem for QSpy that I have over here (branch repo)

https://github.com/vChavezB/dpp_qspy_zephyr/tree/repo

You can see from the CI/CD that it builds correctly

https://github.com/vChavezB/dpp_qspy_zephyr/actions/runs/2824061659

Regards Victor

quantum-leaps commented 1 year ago

Hi Victor, It's generally difficult to accept pull requests into a dually-licensed projects, because of potential IP claims. I hope you understand. I also wanted to organize the repos a bit differently. But I tried to give credit in the README.md files. Please let me know if I can do anything else in this regard.

So I ended up creating two additional QuantumLeaps repos:

  1. qpcpp-zephyr module
  2. qpcpp-zephyr-app example application

The application example does not use interrupt-driven UART yet, and QS-RX still doesn't work for me. But generally, that's how I think the Zephyr integration will look like, so perhaps you could try the repos on your end.

Please let me know what you think.

--MMS

vChavezB commented 1 year ago

Yes no problem. Seems fine to me 👍 About the interrupts,its seems strange that it does not work. With an NRF52 board it worked for me in polling and interrupt mode.

As everything is abstracted by Zephyr it could be that there is a bug on the board you are using. Would need to go down the rabbit hole to debug the Zephyr Uart driver. Anyways Ill check the last changes you have made.

quantum-leaps commented 1 year ago

Actually, today I changed it a bit and made it perhaps more "elegant". So, instead of separate qpcpp-zephyr repo, the qpcpp repo itself is now a Zephyr module. Specifically, at the root of qpcpp there is now zephyr folder that contains also the port and all the stuff. In other words, you can use QuantumLeaps/qpcpp instead of qpcpp-zephyr (which was deleted). The repo qpcpp-zephyr-app demonstrates the use of the qpcpp "Zephyr module". Could you perhaps give it a try in your project? This seems to be the way forward.

Regarding the UART, the project in qpcpp-zephyr-app does not yet use interrupt-driven UART (just see the bsp.cpp in that project). I would need to work on that, but it's taken a humongous amount of time already...

--MMS

quantum-leaps commented 1 year ago

Hi Victor, I've done still some changes to the QPCPP Zephyr module, which might impact your work. Please see the qpcpp-zephyr-app repo for changes, but QSPY is no longer in KConfig. Instead this is a regular option, which you might define either in your CMakeLists.txt for the project (see qpcpp-zephyr-app repo) or on the command line.

The DPP example (in the qpcpp-zephyr-app repo) works well with QSPY. The UART interface is interrupt-driven QS-RX. Also, there is no special qspy thread, but instead the Zephyr main thread is reused to to the QSPY data TX and RX.

I hope you'll like the changes.

--MMS

vChavezB commented 1 year ago

Thanks for the info. I will definitely check it out.