|
SatCat5
|
Core event-processing loop for SatCat5 software.
This file defines the main event-processing loop for all SatCat5 software. To function properly, SatCat5 requires users to connect several subsystems to platform-specific logic:
while(1) {satcat5::poll::service_all();}SatCat5 event-processing is single-threaded. Each call to the main service function (i.e., satcat5::poll::service_all()) processes all queued events in sequence.
There are three built-in event types:
Definition in file polling.h.
Go to the source code of this file.
Classes | |
| class | satcat5::poll::Always |
| An "Always" object is polled whenever service() is called. More... | |
| class | satcat5::poll::OnDemand |
| An "OnDemand" object is polled only on request. More... | |
| class | satcat5::poll::Timekeeper |
| Global coordinator for multiple Timer objects. More... | |
| class | satcat5::poll::Timer |
| Timer objects are polled after a fixed delay or at a regular interval. More... | |
| class | satcat5::poll::TimerAdapter |
| Connect a Timer to any OnDemand object. More... | |
| class | satcat5::irq::VirtualTimer |
| Poll any OnDemand object using a TimeRef. More... | |
Functions | |
| void | satcat5::poll::service () |
| Single-pass service loop. More... | |
| void | satcat5::poll::service_all (unsigned limit=100) |
| Multi-pass service loop Calling this function regularly is required for SatCat5 operation. More... | |
| bool | satcat5::poll::pre_test_reset () |
| Hard-reset of global variables at the start of each unit test. More... | |
Variables | |
| Timekeeper | satcat5::poll::timekeeper |
| There is a single global instance of the Timekeeper class. More... | |
| bool satcat5::poll::pre_test_reset | ( | ) |
Hard-reset of global variables at the start of each unit test.
(Unit testing only, should not be called in production.)
A hard reset may leak memory but prevents contamination of global state across tests, which can be extremely difficult to debug. Returns true if globals were already in the expected state.
Definition at line 134 of file polling.cc.
| void satcat5::poll::service | ( | ) |
Single-pass service loop.
This function processes all queued events, then returns. Most users should instead call service_all().
Definition at line 143 of file polling.cc.
| void satcat5::poll::service_all | ( | unsigned | limit = 100 | ) |
Multi-pass service loop Calling this function regularly is required for SatCat5 operation.
This is the preferred service method, because it will continue processing queued events until the queue is empty or the iteration limit is reached. Iterated polling is preferred because on-demand event processing often triggers additional event(s). (For example, incoming data from a UART may pass data to a SLIP decoder, which may pass data to an IPv4 stack.)
Users must call this method frequently.
Definition at line 157 of file polling.cc.
|
extern |
There is a single global instance of the Timekeeper class.
User MUST link it to a once-per-millisecond event source such as a hardware interrupt or the VirtualTimer.
Definition at line 50 of file polling.cc.