Course contentsShow

Module 09 · Lesson 1

Flight Software Patterns

Flight software from different organizations looks alike because the constraints are alike. This lesson covers the common structure, the message bus pattern, cFS and F Prime, and memory discipline.

8 minute readUpdated November 23, 2026

Learning objectives

After this lesson you will be able to:

  • Explain how limited processors, real-time deadlines and unattended operation shape flight software structure
  • Describe the common building blocks - scheduler, components on a message bus, tables, command and telemetry handling, fault protection and modes
  • Summarize what the cFS and F Prime frameworks provide and why dynamic memory allocation is avoided after initialization

Why flight software looks the way it does

The foundation course explained why flight software is constrained. This lesson describes the structure those constraints produce. Flight software from different organizations is surprisingly similar, because the same pressures lead to the same answers.

One point should be clear from the start. Flight software is typically written in C or C++. The TypeScript in this lesson illustrates a pattern and nothing more.

Constraints that shape the design

Limited processors. Traditional radiation-hardened flight computers run at tens to a few hundred megahertz, with memory measured in megabytes, not gigabytes. Newer designs and small satellites using commercial parts have much more, but processor time and memory are still budgeted with margin, like mass and power.

Real-time deadlines. An attitude control loop must read sensors, compute and command actuators at a fixed rate, commonly between once and tens of times a second. A late answer is a wrong answer. Worst-case execution time matters more than average speed.

No operator at the keyboard. The software runs for years without a restart if all goes well, and must recover by itself if it does not. Anything that could accumulate, such as memory leaks, counter overflows or queues that grow, eventually will.

A common structure

Most flight software is built in layers. Hardware-specific code sits at the bottom, a real-time operating system and shared services sit in the middle, and mission functions sit on top. The usual elements are as follows.

  • A real-time operating system or scheduler. Tasks have fixed priorities and run at fixed rates. Many designs divide time into repeating slots and assign each activity a slot, so the processor load is known by construction.
  • Components on a message bus. Functions are packaged as components, also called applications, such as attitude control, power management and thermal control. They do not call each other. They exchange messages through a software bus.
  • Table-driven configuration. Limits, schedules, filter settings and routing are held in tables that can be loaded in flight.
  • Command and telemetry handling. One component receives commands from the radio, checks them and publishes each to its destination. Another collects telemetry messages and passes them to the downlink or to storage.
  • Fault protection. Monitors watch telemetry against limits and trigger predefined responses, up to and including safe mode.
  • Modes. The system has a small set of defined modes, such as safe, standby and nominal, with controlled transitions. Each mode determines which components are active and which commands are allowed.

The parallel with a microservice architecture is real: independent units, explicit message contracts, and observability built in. It breaks down on resources. Everything is statically sized, usually runs on one processor, and must meet deadlines measured in milliseconds.

The message bus pattern

The example shows the core of a software bus. Each subscriber owns a bounded queue, called a pipe here. Publishing copies a message into the pipe of every subscriber to that message identifier.

interface Message { id: number; payload: Uint8Array }
// A pipe is a bounded queue owned by one subscribing component.
interface Pipe { name: string; depth: number; queue: Message[]; dropped: number }
const makePipe = (name: string, depth: number): Pipe => ({ name, depth, queue: [], dropped: 0 });

class MessageBus {
  private routes = new Map<number, Pipe[]>();
  subscribe(msgId: number, pipe: Pipe): void {
    this.routes.set(msgId, [...(this.routes.get(msgId) ?? []), pipe]);
  }
  // Returns how many pipes took the message. The publisher never learns who they are.
  publish(msg: Message): number {
    let delivered = 0;
    for (const pipe of this.routes.get(msg.id) ?? []) {
      // A full pipe drops the message and counts the loss. It never grows.
      if (pipe.queue.length >= pipe.depth) { pipe.dropped++; continue; }
      pipe.queue.push(msg);
      delivered++;
    }
    return delivered;
  }
}

const ATTITUDE_STATE = 0x0801; // illustrative message identifier
const bus = new MessageBus();
const telemetryOut = makePipe("telemetry-output", 4);
const faultProtection = makePipe("fault-protection", 1);
bus.subscribe(ATTITUDE_STATE, telemetryOut);
bus.subscribe(ATTITUDE_STATE, faultProtection);

console.log(bus.publish({ id: ATTITUDE_STATE, payload: new Uint8Array([1]) })); // 2
console.log(bus.publish({ id: ATTITUDE_STATE, payload: new Uint8Array([2]) })); // 1 - one pipe was full
console.log(bus.publish({ id: 0x0999, payload: new Uint8Array([3]) }));         // 0 - no subscribers
console.log(telemetryOut.queue.length, faultProtection.dropped);                // 2 1

Three properties carry over to real flight software. The publisher does not know who is listening, so a recorder or a monitor can be added without touching it. Each subscriber processes its pipe in its own task at its own rate. And a full pipe drops the message and counts the loss. It never grows. A real implementation would use fixed arrays allocated at startup and would report the overflow as an event.

Open-source frameworks from NASA

Two NASA frameworks are public and worth reading.

The core Flight System (cFS) comes from NASA's Goddard Space Flight Center. It is written in C and organized in layers: an operating system abstraction layer, a platform support package for the specific hardware, and the core Flight Executive, which provides executive, software bus, event, table and time services. Mission functions are written as applications that run on top and communicate over the software bus. cFS has flown on a number of NASA missions.

F Prime comes from NASA's Jet Propulsion Laboratory. It is a component-based framework in C++. Components declare typed ports and are wired together in a topology, and much of the connecting code is generated from a model of the components and their connections. Commands, telemetry channels and events are part of each component's definition. F Prime was designed with smaller systems such as CubeSats and instruments in mind, and it was used for the flight software of the Ingenuity Mars Helicopter.

The two differ in style, but both implement the structure described above.

Memory management and defensive practice

The best-known rule is to avoid dynamic memory allocation after initialization. All buffers, queues and pools are created at startup with fixed sizes. Run-time allocation can fragment memory, can fail, and takes a variable amount of time. With static sizing, worst-case memory use is established before launch.

Related practices follow the same logic of bounding everything:

  • loops have fixed upper limits, and recursion is avoided so that stack depth can be analyzed
  • every return value is checked, and every queue and buffer reports when it overflows
  • coding standards restrict the language to a well-understood subset, and static analysis enforces them
  • counters and timers are checked for what happens when they wrap

These rules feel restrictive to engineers used to managed runtimes. Their purpose is to make behavior analyzable.

A practical example: adding a battery heater controller

A mission needs a new function: hold the battery between 10 and 20 degrees Celsius using two heaters. In a bus-based design this becomes one new component.

  • Inputs. It subscribes to the thermal telemetry message that already carries the battery temperatures. The thermal component is not modified.
  • Outputs. It publishes heater on and off requests to the power component's existing command message, and its own housekeeping message with heater states and counters.
  • Configuration. Set points and the limits beyond which it gives up and raises a fault are placed in a table, so they can be adjusted as the battery ages.
  • Commands. Enable, disable, and a no-operation command for testing the command path. Each is added to the telemetry and command database.
  • Budgets. The component runs once a second. Its worst-case execution time is measured and added to the processor budget, its pipe depth is sized for the message rate, and its memory is allocated at startup.
  • Fault protection. A monitor is added for a heater that is on while the temperature is above its limit.

The component is tested alone by publishing recorded temperature messages and checking the heater requests that come out. Nothing else in the flight software changes except configuration, which is the property the architecture exists to provide.

Flight software produces the packets and consumes the commands. The next lesson looks at the ground software on the other end of the link, where the constraints are very different.

Key takeaways

  • Flight software is typically written in C or C++ and built from components that exchange messages over a software bus, on top of a real-time operating system.
  • Publishers do not know their subscribers. That decoupling lets components be tested alone, reused between missions and extended without changing existing code.
  • Behavior that may need to change in orbit is put in tables, which can be validated and loaded as data without rebuilding the software.
  • Memory is allocated at startup and bounded everywhere, so the worst case can be analyzed before launch instead of discovered after it.

Knowledge check

Check your understanding. These questions are not graded and you can retry as often as you like.

Question 1 of 3· Select one answerWhy do flight software teams usually forbid dynamic memory allocation after initialization?
Question 2 of 3· Select all that applyWhich of these are genuine benefits of building flight software from components on a message bus? Select all that apply.
Question 3 of 3· Select one answerA fault monitor's temperature threshold needs to change after a year in orbit. Why is it valuable that the threshold is held in a table and not in code?

0 of 3 questions answered.

Glossary

Real-time operating system

An operating system designed so that tasks meet their deadlines predictably, typically using fixed task priorities and bounded response times.

Software bus

A messaging service inside the flight software that routes each published message to the components subscribed to its message identifier.

Component

A self-contained unit of flight software with a defined set of commands, telemetry and message interfaces. Some frameworks call it an application.

Table-driven configuration

Holding thresholds, schedules and other adjustable settings in data tables that can be validated and replaced in flight without changing the executable code.

cFS

The core Flight System, an open-source flight software framework from NASA's Goddard Space Flight Center.

F Prime

An open-source, component-based flight software framework from NASA's Jet Propulsion Laboratory.

References and further reading

Finished this lesson?

Loading your progress…

Lesson version 1.0.0.