Skip to main content

fsd9lib

A Python library for the FSD (Flight Simulator Data) protocol version 9 — the classic VATSIM-compatible protocol for flight simulation networking.

Zero dependencies — uses only Python's standard library (asyncio).

Features

  • Full FSD protocol v9 packet construction and parsing
  • PBH (Pitch/Bank/Heading) encoding/decoding
  • Radio frequency encoding/decoding
  • Async TCP connection with auto-reconnect
  • High-level PilotClient for crew (pilot) connections
  • Callback-based message/position/error handling
  • Complete enum types: ratings, facility types, simulator types, error codes, etc.

Installation

pip install fsd9lib

Quick Start

import asyncio
from fsd9 import PilotClient, NetworkRating, SimulatorType

async def main():
    # Create a pilot client
    client = PilotClient(
        callsign="N7938C",
        cid="123456",
        password="your_vatsim_password",
        server="eu.velocity.vatsim.net",
        real_name="John Doe",
        sim_type=SimulatorType.MSFS2020,
    )

    # Register callbacks
    async def on_message(client, sender, text):
        print(f"[{sender}] {text}")

    async def on_position(client, callsign, data):
        print(f"  {callsign} @ {data['lat']:.4f}, {data['lon']:.4f} "
              f"FL{data['altitude_true'] // 100} "
              f"GS={data['ground_speed']}kt "
              f"HDG={data['heading']:.0f}°")

    client.on_message = on_message
    client.on_position = on_position

    # Connect and login
    await client.connect()
    print(f"Connected as {client.callsign}")

    # File a flight plan
    await client.file_flight_plan(
        flight_rules="I",
        equipment="H/B738/L",
        tas=450,
        dep_airport="KLAX",
        dest_airport="KSFO",
        cruise_alt=35000,
        hrs_enroute=1,
        min_enroute=30,
        route="VTU5 RZS STOKD SERFR SERFR3",
    )

    # Send position updates
    await client.send_position(40.65906, -73.79891, 35000, 450, 2.0, 0.0, 90.0)

    # Send a text message on frequency
    await client.send_radio_message(122.800, "Traffic in sight")

    # Keep running
    await asyncio.sleep(60)
    await client.disconnect()

asyncio.run(main())

Auto-Position Mode

client = PilotClient(
    callsign="N7938C",
    cid="123456",
    password="secret",
    auto_position=True,     # Automatically send position every 5s
    position_interval=5.0,  # Customize interval
)

await client.connect()

# Set the position once — it will repeat automatically
await client.send_position(40.659, -73.798, 35000, 450)

Low-Level Packet API

Build and parse individual packets without a connection:

from fsd9 import packet, frequency, pbh

# Pack PBH
pbh_val = pbh.pack(pitch=2.0, bank=0.0, heading=90.0)
pitch, bank, heading, on_ground = pbh.unpack(pbh_val)

# Encode frequency
wire = frequency.encode(122.800)  # → 22800
mhz = frequency.decode(22800)     # → 122.800

# Build packets
login = packet.build_add_pilot("N7938C", "123456", "pass")
pos = packet.build_pilot_position("N7938C", "N", 0o2000,
    NetworkRating.OBS, 40.659, -73.798, 35000, 450, 2.0, 0.0, 90.0)

Protocol Version

This library implements FSD protocol revision 9 (classic/legacy), which uses plaintext password authentication. It does NOT support:

  • VATSIM Auth (revision 100) — challenge-response MD5
  • VATSIM JWT (revision 101) — JWT tokens
  • VATSIM Velocity fast positions (revision 101+)

License

AGPL-3.0

Release files for fsd9lib 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fsd9lib 0.1.0
File Size Uploaded
fsd9lib-0.1.0.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fsd9lib 0.1.0
File Interpreter ABI Platform
fsd9lib-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.5 kB

Release files / fsd9lib-0.1.0.tar.gz

Download URL fsd9lib-0.1.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
22b46c88a2a2216677e474223893efbae0c34aa1ae0f3a829f53def6d531fd23
BLAKE2b-256 checksum
How to use checksums
b989b2617ea4ad508cb2530192059f523d77ebb3bafddf64f27e3565edd0f03f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / fsd9lib-0.1.0-py3-none-any.whl

Download URL fsd9lib-0.1.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbf048fc9de24d62b172c4cc324f315ff0f98ee8f3b816e0b896b83ec3825df7
BLAKE2b-256 checksum
How to use checksums
3436ceb4c5227b616bd62e13509efa4ae8a2757b784e413e0ce92f7f451fffc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page