How to wait or sleep in a component? #1014
Replies: 2 comments 2 replies
-
It's actually a good question. If by "sleep" you mean wait a specified amount of time for the reset to complete so you can talk to it, I usually decrement a counter in the scheduler call until it reaches the time I want to wait, then start talking again. That way the component execution won't block waiting for the time to pass. |
Beta Was this translation helpful? Give feedback.
-
This is how you do what I suggested. Create a private variable in your component: U32 m_resetCntDown; Assume for the sake of discussion that you call your rate group port 1/sec, and that it takes the GPS 5 seconds to fully reset. When you command the reset, you do this: m_resetCntDown = 5 Each time the rate group gets called, you do:
In the same call, you check: if (m_resetCntDown == 0) {
// start operating GPS again
} That way, your component never blocks. |
Beta Was this translation helpful? Give feedback.
-
Probably a dumb question but I am trying to sleep in my gps component after resetting it. My Gps Component is also connected to the Health Ping, so when I sleep it stops replying to those pings.
Is there a better way to delay to wait in fprime without missing the pings?
Beta Was this translation helpful? Give feedback.
All reactions