Receiving File Read Responses

Hello,

I have an application which runs on STM32 Bare Metal Target. It is a node device and it sends UAVCAN messages and receives them.

My device already works, but it is lack of something: firmware update. I am trying to add firmware update via uavcan to my device. I’ve already received the File.read responses, but there is one problem. My program’s begin firmware update handler looks like below:

This is my handler function to handle begin firmware update request. It works well. When i receive the request, i can respond to it. The problem starts here:

As you know, the program which does these kind of things simply have a loop. That loop does receiving, spinning and publishing stuff. When i write my code like this, i am able handle receive File.Read responses with my handler function handleFileReadResponse. The code is given below.

As you see, i am sending my read file requests in firmware update handler, and it jus works. I am receiving the Read.File responses correctly. But i do not wanna stop the main loop, so i wanna update a flag when request is the received and control it in every loop iteration. I wanna design something like this:

This is the main loop which i am planning to control firmware update process.

image

This loop just does not work! I mean, i send read file requests correctly, i montior them by Drone_CAN, but i just can not receive the responses.

I didn’t understand the underlying reason. When i send my requests inside Begin firmware update request handler, i am receiving File.read responses. But when i send them outside of this function, it just doesn’t work.

I could misunderstood the flow logic of uavcan program or library etc. I wanna be informed about this, could you please give me useful resources or recommendations about my situation?

Thank you.

This is a general programming question that is not related to DroneCAN/Cyphal.

Where should i ask it?

An LLM like ChatGPT should be able to help with this better than any human mentor.