WindhoverLabs / airliner

7 stars 3 forks source link

LD App Main loop frequency #349

Open ynielson opened 1 year ago

ynielson commented 1 year ago

I found that the Land Detector Update Rate is 50 Hz in ld_app.h, which is defined as "static constexpr uint32 LAND_DETECTOR_UPDATE_RATE_HZ = 50;" And the comment said to run Main loop at this rate in Hz. 50 cycles in 1 second(1000 miliseconds).

And the LAND_DETECTOR_TRIGGER_TIME_US is defined 300000 microsecond(300 miliseconds). This macro is used to detect Landed state. This means that even though Landed state is changed from TRUE to FALSE, it will not trigger the landed state until 300 miliseconds passed for some reason.

From the above 50 Hz recommended for this code, the main loop should run 15 cycles in 300 miliseconds. So in case any data was changed during that 15 cycles, the hold Landed state may be affected.

But the Sch Pipe Read Msg(CFE_SB_RcvMsg()) blocking time is 2000 miliseconds. This means that the app will wait for 2000 miliseconds in blocking mode, every time it read message from the Sch Pipe when there are no messages in the pipe.

This may affect the original code behavior intended to hold 300 miliseconds before triggering the state. The 2000 miliseconds blocking time will void this intention. Same thing applies to the intention to use GROUND_CONTACT_TRIGGER_TIME_US(350 miliseconds).

I have tried to manipulate the Landed state and ground contact state from the unit test, but the Ut default hook function for reading msg from SB disregard the blocking mode. So the result may be different from the actual app.

I've noticed that most of the apps use the 2000 miliseconds blocking mode to read from the Sch Pipe, except the sbnd app which uses the 4 miliseconds blocking mode.

These may need to be examined.

ynielson commented 1 year ago

I just checked the "sch" app and the schedule table. The WakeUp messages of the LD app and the other several apps are in the 250HZ group and in every slot. So, these apps will not be in blocking for 2000 miliseconds. And the LD app is running faster than the recommanded 50 Hz.

Just one thought is that the LD app do not read all the data messages in the DataPipe per one main loop cycle, which is different from most other apps.

This ticket can be closed.