Legato threading API used in non-Legato thread

My Legato C/C++ application running on an FX30 is giving me this fatal error after running for ~5 minutes.

I do not spawn any threads, all I do at the start of the application is start a Legato timer with a handler function that is implemented as purely a single thread.

Have been trying to read around and help make sense of this error, but haven’t found much.

Do I need to spawn a Legato thread first and then start the timer from within that?

Is the thread which enters COMPONENT_INIT and then runs the application not itself already a Legato thread?

Thanks in advance.
Jul 17 18:47:13 | riotenginelite[1631073074]/framework T=unknown | LE_FILENAME GetCurrentThreadPtr() 461 | Legato threading API used in non-Legato thread!

Hi cmccarthy,

Have you read below relate to non-Legato thread?

Are you able to find which part of app code throw this error? If yes, you may follow the doc to call the API.


I have read that information, but like I said, I am starting no new threads within the application.

When I try to call le_thread_InitLegatoThreadData() function from either COMPONENT_INIT or on the first tick of the timer in its handler function, I get an error saying that the Legato thread data has already been initialized on that thread (which I suspected was the case, as it would be odd if the application was started with a non-Legato thread).

Unfortunately I cannot pin down the exact line of code, as the code runs fine for about 10 minutes, during which it is periodically and successfully sending some data to a cloud server. It essentially just does this in a loop, but for whatever reason, after running successfully for around 10 minutes, I get that “Legato threading API used in non-Legato thread” fatal error.

@cmccarthy, what exactly are you doing inside the timer handler? Are you subscribing to event handlers?