Recursive Calls to app_sched_execute()

Hi,

I am coming across an issue with app_scheduler and FDS.

While waiting for an event in FDS to complete (write, read, init, gc, etc) I go into a while loop calling app_sched_execute() until the event handler is invoked and I can continue. However, I am running into an issue where I am calling an fds Write from a scheduler event. The repeated call to app_sched_execute() means the same command is executed over and over again until the FDS runs out of Queue Space and I hit the Error Handler.

Is there a way to safely wait for the FDS to complete a task without causing this recursion?

Thanks

Parents
  • Hi,

    It is not possible to call app_sched_execute() from a scheduled event, as the event is first popped from the queue first after the event is done, as the event data pointer needs to be kept throughout the event.

    I'm not sure I fully understand how you use the scheduler to wait for completion of FDS operations, can you give a code example showing how this works?

    Do you have to wait for the completion of the operation by calling app_sched_execute(), or could you wait for a flag from the FDS event handler instead?

    Best regards,
    Jørgen

  • Hi,

    It you have The softdevice handler library configured to use NRF_SDH_DISPATCH_MODEL_APPSH, you are correct that you need to call app_sched_execute() to process the events from the Softdevice, which in turn will trigger the Fstorage/FDS event handlers.

    Is sd_app_sched_execute( ); on line 70 a typo? I could not find this function in the SDK.

    I'm also not sure I understand where the recursive call issue is coming from. In the code you posted, I can't see app_sched_execute() being called from any scheduler event handlers?

    Best regards,
    Jørgen

  • Hi Jørgen,

    My NRF_SDH_DISPATCH_MODEL is configured as _APPSH.

    Line 70 is a typo, it should read app_sched_execute();, There was a mistake made when creating the code to post on here.

    The code above is an extract of how I am setting up my FDS. The recursive issue comes when data is written to a BLE characteristic. This causes an event to be posted onto the scheduler and within this event there is a call to write to storage. Within this write function (which I want to be blocking) there is a call to Storage_Wait() which is where the recursive issue happens.

    Thanks

Reply
  • Hi Jørgen,

    My NRF_SDH_DISPATCH_MODEL is configured as _APPSH.

    Line 70 is a typo, it should read app_sched_execute();, There was a mistake made when creating the code to post on here.

    The code above is an extract of how I am setting up my FDS. The recursive issue comes when data is written to a BLE characteristic. This causes an event to be posted onto the scheduler and within this event there is a call to write to storage. Within this write function (which I want to be blocking) there is a call to Storage_Wait() which is where the recursive issue happens.

    Thanks

Children
No Data
Related