This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[Solution] working with CLI on a FreeRTOS system

Hi guys

I had to integrate a CLI module into a project I'm working on, that is running FreeRTOS

after quite a lot of work, I managed to get this working, but seeing as there is very little documentation and this has been asked in the past, I though it would be wise to write my findings, in case someone needs this in the future (sorry if this is the wrong section of the site for this)

the main issue with adapting the CLI example to work with FreeRTOS revolves around times, due to how differently they are implemented when running on an operating system

from our findings when trying to get this to work, the timer API from app_timer_freertos doesn't properly work, thus we resorted to using FreeRTOS commands directly, mainly xTimerCreate for creating the timer, and xTimerStartFromISR to restart the timer (as the CLI timer is started in one shot mode). when doing so, make sure to go over the API of xTimerCreate carefully, especially regarding passing data to the timer callback function, as doing so improperly will break the program flow as events won't get triggered

make sure to run the CLI functions from a task instead of the main loop, and everything should work

on a side note, at least for SDK 15.2 which we're using in the project, there were several issues when trying to disable some of the CLI command modules from sdk_config.h, as some of their uses aren't properly enclosed in #if statements

so if you plan on removing some of the default commands seen in the example, you will probably need to edit some of the library code to prevent these compilation issues

other than that, feel free to ask if you have some issues, as I may have forgotten about some of the changes I had to do to get this to work

I hope this helps others, as we've spent a lot of time trying to get this to work

best regards

Aviv

Related