### HTTP API Server Setup and Querying Source: https://context7.com/wiedehopf/readsb/llms.txt Starting the built-in HTTP API server and querying aircraft data using curl and jq. ```bash readsb --net-only --net-connector 192.168.1.100,30005,beast_in --write-json /run/readsb --net-api-port 8042 --write-json-every 1 curl -sS 'http://localhost:8042/?all_with_pos' | jq ``` -------------------------------- ### Start API Server Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Starts the built-in webserver for the API on a specified port. This server can then handle various query formats to retrieve aircraft data. ```bash --net-api-port 8042 ``` -------------------------------- ### Readsb Systemd Service Configuration Source: https://context7.com/wiedehopf/readsb/llms.txt Example of a systemd service file for readsb, enabling it to run as a background service. It includes unit, service, and install sections with essential configuration parameters and restart policies. ```ini # /etc/systemd/system/readsb.service [Unit] Description=readsb ADS-B receiver Documentation=https://github.com/wiedehopf/readsb Wants=network.target After=network.target [Service] User=readsb RuntimeDirectory=readsb RuntimeDirectoryMode=0755 ExecStart=/usr/bin/readsb \ --device-type rtlsdr \ --gain auto \ --ppm 0 \ --net \ --quiet \ --lat 51.5074 \ --lon -0.1278 \ --max-range 450 \ --write-json /run/readsb \ --write-json-every 1 \ --json-location-accuracy 2 \ --net-ri-port 30001 \ --net-ro-port 30002 \ --net-sbs-port 30003 \ --net-bi-port 30004,30104 \ --net-bo-port 30005 Type=simple Restart=always RestartSec=30 Nice=-5 [Install] WantedBy=default.target ``` -------------------------------- ### Install tar1090 web interface Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Steps to clone the tar1090 repository and download the necessary aircraft database file for the web interface. ```bash git clone --depth 1 https://github.com/wiedehopf/tar1090 ~/tar1090 wget -O ~/tar1090/aircraft.csv.gz https://github.com/wiedehopf/tar1090-db/raw/csv/aircraft.csv.gz ``` -------------------------------- ### Run readsb with basic options Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Example command to run readsb with essential options for quiet operation, network connectivity, and automatic gain control for the RTLSDR device. ```bash ./readsb --quiet --net --device-type rtlsdr --gain auto ``` -------------------------------- ### Debian Package Installation for Readsb with RTLSDR Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Shell commands to install readsb from a Debian package, including necessary build dependencies and RTLSDR support. This process involves updating apt, installing packages, cloning the repository, building the package, and installing it. ```bash sudo apt update sudo apt install --no-install-recommends --no-install-suggests -y git build-essential debhelper libusb-1.0-0-dev pkg-config fakeroot libncurses-dev zlib1g-dev libzstd-dev librtlsdr-dev help2man git clone --depth 20 https://github.com/wiedehopf/readsb.git cd readsb export DEB_BUILD_OPTIONS=noddebs rm -f ../readsb_*.deb dpkg-buildpackage -b -ui -uc -us --build-profiles=rtlsdr sudo dpkg -i ../readsb_*.deb ``` -------------------------------- ### Serve tar1090 HTML with Python Source: https://github.com/wiedehopf/readsb/blob/dev/README.md A simple command to start a local HTTP server using Python's built-in module to serve the tar1090 HTML files. ```bash cd ~/tar1090/html python3 -m http.server 8081 ``` -------------------------------- ### Configure readsb database output Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Example of specifying a database file path for readsb to write aircraft data, typically used for logging or further analysis. ```bash ./readsb --db-file ~/tar1090/aircraft.csv.gz ``` -------------------------------- ### GET / Source: https://context7.com/wiedehopf/readsb/llms.txt Retrieves the current list of tracked aircraft from the readsb instance. ```APIDOC ## GET / ### Description Retrieves a list of aircraft currently tracked by the readsb instance. Supports filtering to include or exclude aircraft without position data. ### Method GET ### Endpoint http://localhost:[PORT]/ ### Parameters #### Query Parameters - **all_with_pos** (flag) - Optional - If present, returns only aircraft that have a valid position. - **all** (flag) - Optional - If present, returns all tracked aircraft, including those without position data. ### Request Example curl -sS 'http://localhost:8042/?all_with_pos' ### Response #### Success Response (200) - **now** (float) - Current server timestamp. - **resultCount** (integer) - Total number of aircraft returned. - **ptime** (float) - Processing time in milliseconds. #### Response Example { "now": 1609275898.495, "resultCount": 42, "ptime": 2.5 } ``` -------------------------------- ### Readsb Debian Package Build Options Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Examples of `dpkg-buildpackage` commands for building readsb Debian packages with different build profiles, such as no additional receiver library dependencies, RTLSDR support, or comprehensive SDR support. ```bash dpkg-buildpackage -b -ui -uc -us dpkg-buildpackage -b -ui -uc -us --build-profiles=rtlsdr dpkg-buildpackage -b -ui -uc -us --build-profiles=with_sdrs ``` -------------------------------- ### Build readsb on macOS Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Instructions for compiling the readsb software on macOS using Homebrew. This involves installing dependencies like git, librtlsdr, libusb, and ncurses, then building the project with make. ```bash git clone --depth 1 https://github.com/wiedehopf/readsb.git cd readsb brew install git librtlsdr libusb ncurses make -j4 RTLSDR=yes ``` -------------------------------- ### GET / (Geographic Queries) Source: https://context7.com/wiedehopf/readsb/llms.txt Query aircraft based on geographic location using bounding boxes, radius, or proximity searches. ```APIDOC ## GET / ### Description Retrieve a list of aircraft filtered by geographic criteria. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **box** (string) - Optional - Comma-separated coordinates: lat_south, lat_north, lon_west, lon_east - **circle** (string) - Optional - Comma-separated values: lat, lon, radius_nm - **closest** (string) - Optional - Comma-separated values: lat, lon, max_radius ### Response #### Success Response (200) - **aircraft** (array) - List of aircraft objects within the specified area. ``` -------------------------------- ### GET / (Search Queries) Source: https://context7.com/wiedehopf/readsb/llms.txt Search for specific aircraft using ICAO hex codes, callsigns, registration, or aircraft type. ```APIDOC ## GET / ### Description Search for aircraft using various identifiers. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **find_hex** (string) - Optional - Comma-separated ICAO hex codes - **find_callsign** (string) - Optional - Comma-separated callsigns - **find_reg** (string) - Optional - Comma-separated registrations - **find_type** (string) - Optional - Comma-separated aircraft types ``` -------------------------------- ### Fetch and Query Receiver Statistics with curl and jq Source: https://context7.com/wiedehopf/readsb/llms.txt This example shows how to retrieve receiver statistics from the readsb service using `curl` and process the JSON output with `jq`. It demonstrates fetching the entire stats.json file and specifically extracting message counts from the last minute. ```bash # Read statistics file curl -sS 'http://localhost/tar1090/data/stats.json' | jq # Get message counts from last minute curl -sS 'http://localhost/tar1090/data/stats.json' | \ jq '.last1min.messages' ``` -------------------------------- ### Readsb Network Connectors for Data Forwarding Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Examples of readsb command-line arguments for connecting to a listening server to send or receive ADS-B data in Beast format. This includes options for raw beast data and a reduced format with optional UUID. ```bash --net-connector 192.168.2.22,30004,beast_out --net-connector 192.168.2.28,30005,beast_in --net-connector=feed.airplanes.live,30004,beast_reduce_plus_out,uuid=0033062d-e17e-4389-91a9-79ebb967fb4c ``` -------------------------------- ### GET /aircraft.json Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Retrieves a snapshot of recently seen aircraft tracked by the readsb system. ```APIDOC ## GET /aircraft.json ### Description Returns a JSON object containing the current timestamp, total message count, and an array of aircraft objects currently being tracked. ### Method GET ### Endpoint /aircraft.json ### Response #### Success Response (200) - **now** (number) - Unix epoch timestamp of generation - **messages** (number) - Total Mode S messages processed - **aircraft** (array) - List of tracked aircraft objects #### Response Example { "now": 1672531200, "messages": 123456, "aircraft": [ { "hex": "AABBCC", "type": "adsb_icao", "flight": "FLIGHT01", "lat": 51.5074, "lon": -0.1278, "alt_baro": 35000 } ] } ``` -------------------------------- ### Nginx configuration for tar1090 Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Example Nginx server block configuration to serve tar1090's data, history, and HTML files, enabling access to the web interface. ```nginx location /tar1090/data/ { alias /home/USER/tar1090/data/; add_header Cache-Control "no-cache"; location /tar1090/data/traces/ { gzip off; add_header Content-Encoding "gzip"; add_header Cache-Control "no-cache"; } } location /tar1090/globe_history/ { alias /home/USER/readsb_history/; gzip off; add_header Content-Encoding "gzip"; add_header Cache-Control "no-cache"; } location /tar1090 { alias /home/USER/tar1090/html/; add_header Cache-Control "no-cache"; } ``` -------------------------------- ### GET /data/aircraft.json Source: https://context7.com/wiedehopf/readsb/llms.txt Retrieve the full current state of all tracked aircraft in JSON format. ```APIDOC ## GET /data/aircraft.json ### Description Returns the complete list of tracked aircraft and system status. ### Method GET ### Endpoint /data/aircraft.json ### Response #### Success Response (200) - **now** (integer) - Current timestamp in milliseconds - **messages** (integer) - Total messages processed - **aircraft** (array) - List of aircraft objects containing detailed telemetry data. ``` -------------------------------- ### Query Aircraft Data with Curl Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Examples of using curl to query the API for specific aircraft data. The results can be piped to tools like jq for further processing. ```bash curl -sS 'http://localhost:8042/?hexlist=3CD6E3' | jq ``` -------------------------------- ### GET / Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md The primary endpoint for querying aircraft data. Supports various base query types and optional filters to refine the returned dataset. ```APIDOC ## GET / ### Description Retrieves aircraft data based on spatial, identifier, or status-based queries. Results can be further refined using optional filter parameters. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **circle** (string) - Optional - Format: ,,. Returns aircraft within radius. - **closest** (string) - Optional - Format: ,,. Returns the single closest aircraft. - **box** (string) - Optional - Format: ,,,. Returns aircraft within the rectangle. - **all** (boolean) - Optional - Returns all tracked aircraft. - **find_hex** (string) - Optional - Comma-separated list of ICAO hex codes. - **find_callsign** (string) - Optional - Comma-separated list of callsigns. - **filter_mil** (boolean) - Optional - Filter for military aircraft. - **jv2** (boolean) - Optional - Toggle ADSBExchange v2 compatible JSON output. ### Request Example GET /?circle=51.5,-0.1,50&filter_mil ### Response #### Success Response (200) - **now** (number) - Unix timestamp of cache time. - **resultCount** (number) - Number of aircraft returned. - **aircraft** (array) - List of aircraft objects. #### Response Example { "now": 1672531200, "resultCount": 1, "aircraft": [ { "hex": "3CD6E3", "dst": 12.5, "dir": 180 } ] } ``` -------------------------------- ### GET /status Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Checks the operational status of the Readsb API. ```APIDOC ## GET /status ### Description Returns the current health status of the API service. ### Method GET ### Endpoint /status ### Response #### Success Response (200) - **status** (string) - Returns 200 during normal operation. ``` -------------------------------- ### GET /trace Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Retrieves the historical trace data for a specific aircraft, including position, altitude, speed, and status flags. ```APIDOC ## GET /trace ### Description Returns the historical trace of an aircraft identified by its ICAO hex code. The trace consists of an array of state vectors recorded over time. ### Method GET ### Endpoint /trace ### Parameters #### Query Parameters - **icao** (string) - Required - The 6-character hex ID of the aircraft. ### Response #### Success Response (200) - **icao** (string) - Aircraft hex ID - **timestamp** (number) - Unix timestamp of the trace start - **trace** (array) - Array of position/state arrays #### Response Example { "icao": "3c66b0", "timestamp": 1663259853.016, "trace": [ [7016.59, 49.263300, 10.614239, 25125, 446.5, 309.0, 0, -2176, null, "adsb_icao", 25875, -2208, 335, -10.7] ] } ``` -------------------------------- ### GET / (Filter Options) Source: https://context7.com/wiedehopf/readsb/llms.txt Apply various filters to aircraft queries, such as altitude ranges, squawk codes, or specific callsign patterns. ```APIDOC ## GET / ### Description Apply filters to refine the aircraft dataset returned by the server. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **filter_callsign_exact** (string) - Optional - Exact callsign match - **filter_callsign_prefix** (string) - Optional - Prefix match for callsigns - **filter_squawk** (string) - Optional - Filter by squawk code - **above_alt_baro** (integer) - Optional - Minimum altitude - **below_alt_baro** (integer) - Optional - Maximum altitude - **filter_mil** (boolean) - Optional - Filter for military aircraft ``` -------------------------------- ### GET /aircraft.json Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Retrieves the current list of aircraft tracked by readsb with their associated telemetry and database metadata. ```APIDOC ## GET /aircraft.json ### Description Returns a JSON object containing a list of aircraft currently being tracked by the receiver. Includes real-time ADS-B data, calculated environmental metrics, and optional database-enriched fields. ### Method GET ### Endpoint /aircraft.json ### Parameters #### Query Parameters - **--db-file** (flag) - Optional - Enables lookup of registration and type information from a local CSV database. - **--db-file-lt** (flag) - Optional - Enables long type name lookup. ### Response #### Success Response (200) - **tisb** (array) - List of fields derived from TIS-B data. - **messages** (integer) - Total number of Mode S messages received. - **seen** (float) - Seconds since last message received. - **rssi** (float) - Recent average signal power in dbFS. - **alert** (boolean) - Flight status alert bit. - **spi** (boolean) - Special position identification bit. - **wd/ws** (float) - Calculated wind direction and speed. - **oat/tat** (float) - Calculated air temperatures. - **r** (string) - Aircraft registration (requires --db-file). - **t** (string) - Aircraft type (requires --db-file). - **dbFlags** (integer) - Bitfield for database flags (1: military, 2: interesting, 4: PIA, 8: LADD). - **lastPosition** (object) - Last known position {lat, lon, nic, rc, seen_pos} if current position is older than 60s. #### Response Example { "now": 1625000000.0, "aircraft": [ { "hex": "abcd12", "messages": 150, "seen": 0.5, "rssi": -15.2, "r": "N12345", "t": "B738" } ] } ``` -------------------------------- ### Process aircraft.json with Bash and jq Source: https://context7.com/wiedehopf/readsb/llms.txt Utilize bash commands and jq to quickly extract information from the aircraft.json file. Examples include counting the total number of aircraft and filtering for aircraft with specific emergency squawk codes. ```bash curl -sS 'http://localhost/tar1090/data/aircraft.json' | \ jq '.aircraft | length' ``` ```bash curl -sS 'http://localhost/tar1090/data/aircraft.json' | \ jq '.aircraft[] | select(.squawk == "7700" or .squawk == "7600" or .squawk == "7500")' ``` -------------------------------- ### Configure readsb data sending to aggregator Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Example of configuring readsb to send processed aircraft data to a remote aggregator using a specific format and authentication key. ```bash ./readsb --net-connector feed.flyrealtraffic.com,30004,beast_reduce_plus_out,7817bd08-f226-11ef-ba9e-072eee452592 ``` -------------------------------- ### Process aircraft.json with Python Source: https://context7.com/wiedehopf/readsb/llms.txt Read and parse the aircraft.json file using Python to access current aircraft state data. This example demonstrates extracting timestamp, message counts, and individual aircraft details like ICAO, flight number, position, and altitude. ```python from contextlib import closing from urllib.request import urlopen import json url = "http://localhost/tar1090/data/aircraft.json" with closing(urlopen(url, None, 5.0)) as aircraft_file: aircraft_data = json.load(aircraft_file) print(f"Timestamp: {aircraft_data['now']}") print(f"Total messages: {aircraft_data['messages']}") for a in aircraft_data['aircraft']: hex_id = a.get('hex') lat = a.get('lat') lon = a.get('lon') alt = a.get('alt_baro') flight = a.get('flight', '').strip() if lat and lon: print(f"ICAO: {hex_id} Flight: {flight} " f"Position: {lat:.4f}, {lon:.4f} Alt: {alt}") ``` -------------------------------- ### Readsb Manual Build with Optimization Flags Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Shell commands for manually compiling readsb using the 'make' utility, demonstrating how to enable specific library support (like RTLSDR) and apply optimization flags for performance tuning, including options for older Raspbian versions and general CPU cycle saving. ```bash make make RTLSDR=yes make RTLSDR=yes OPTIMIZE="-Ofast -mcpu=arm1176jzf-s -mfpu=vfp" make AIRCRAFT_HASH_BITS=11 RTLSDR=yes OPTIMIZE="-O3 -march=native" ``` -------------------------------- ### Basic RTL-SDR Configuration Source: https://context7.com/wiedehopf/readsb/llms.txt Commands to initialize readsb with RTL-SDR hardware, enabling network output and JSON status writing for real-time tracking. ```bash readsb --device-type rtlsdr --gain auto --net --lat 51.5074 --lon -0.1278 --write-json /run/readsb --write-json-every 1 --net-ri-port 30001 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005 ``` -------------------------------- ### Readsb Aircraft Database Integration Source: https://context7.com/wiedehopf/readsb/llms.txt Demonstrates how to download and configure the aircraft database for readsb to provide registration and type information. It includes downloading the database file and specifying its path during readsb execution. ```bash wget -O /usr/local/share/tar1090/aircraft.csv.gz \ https://github.com/wiedehopf/tar1090-db/raw/csv/aircraft.csv.gz readsb --device-type rtlsdr --gain auto --net \ --db-file /usr/local/share/tar1090/aircraft.csv.gz \ --db-file-lt ``` -------------------------------- ### Configure Network Connectors for Readsb Source: https://context7.com/wiedehopf/readsb/llms.txt This section outlines the command-line arguments for configuring network connectors in readsb. It covers various protocols including Beast, Raw, SBS, VRS JSON, JSON position output, ASTERIX, and UAT, specifying input and output modes for each. ```bash # Beast binary protocol (most common) --net-connector 192.168.1.100,30005,beast_in # Receive Beast data --net-connector 192.168.1.100,30004,beast_out # Send Beast data # Beast with data reduction (for aggregators) --net-connector feed.example.com,30004,beast_reduce_out # Reduced output --net-connector feed.example.com,30004,beast_reduce_plus_out # With UUID support # Raw protocol (hex messages) --net-connector 192.168.1.100,30001,raw_in --net-connector 192.168.1.100,30002,raw_out # SBS/BaseStation format --net-connector 192.168.1.100,30003,sbs_in --net-connector 192.168.1.100,30003,sbs_out # SBS with JAERO satellite data support --net-connector 192.168.1.100,30003,sbs_in_jaero --net-connector 192.168.1.100,30003,sbs_out_jaero # VRS JSON format --net-connector 192.168.1.100,30006,vrs_out # JSON position output (one object per line) --net-connector 192.168.1.100,30007,json_out # ASTERIX format --net-connector 192.168.1.100,30008,asterix_in --net-connector 192.168.1.100,30008,asterix_out # UAT (978 MHz) data --net-connector 192.168.1.100,30978,uat_in --net-connector 192.168.1.100,30979,uat_replay_out ``` -------------------------------- ### Run readsb with interactive and coordinate options Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Demonstrates running readsb with the --interactive flag for a terminal-based aircraft list and optionally specifying latitude and longitude for location context. ```bash ./readsb --quiet --net --device-type rtlsdr --gain auto --interactive --lat -33.874 --lon 151.206 ``` -------------------------------- ### GET /tar1090/data/stats.json Source: https://context7.com/wiedehopf/readsb/llms.txt Accesses the receiver statistics and performance metrics, including message counts, signal strength, and processing blocks. ```APIDOC ## GET /tar1090/data/stats.json ### Description Provides real-time performance metrics for the receiver, including local and remote message processing counts, signal quality, and track statistics. ### Method GET ### Endpoint /tar1090/data/stats.json ### Response #### Success Response (200) - **latest** (object) - Statistics for the most recent period - **last1min** (object) - Statistics for the last minute - **last5min** (object) - Statistics for the last 5 minutes - **total** (object) - Cumulative statistics #### Response Example { "latest": { "start": 1609275800, "end": 1609275860, "local": { "blocks_processed": 1000, "messages": 15000 } } } ``` -------------------------------- ### GET /tar1090/data/traces/{icao}.json Source: https://context7.com/wiedehopf/readsb/llms.txt Retrieves the recent flight trace data for a specific aircraft identified by its ICAO hex code. ```APIDOC ## GET /tar1090/data/traces/{icao}.json ### Description Retrieves the recent flight trace history for a specific aircraft. The response includes a base timestamp and an array of trace points containing position, altitude, speed, and track information. ### Method GET ### Endpoint /tar1090/data/traces/{icao}.json ### Parameters #### Path Parameters - **icao** (string) - Required - The ICAO hex code of the aircraft (e.g., a1b2c3). ### Response #### Success Response (200) - **icao** (string) - Aircraft ICAO hex code - **r** (string) - Registration number - **t** (string) - Aircraft type - **timestamp** (number) - Base timestamp for the trace - **trace** (array) - List of trace points containing [seconds_offset, lat, lon, alt, gs, track, flags, vert_rate, details, source, geom_alt, geom_rate, ias, roll] #### Response Example { "icao": "a1b2c3", "r": "N12345", "t": "B738", "timestamp": 1609275898.495, "trace": [[7016.59, 49.2633, 10.6142, 25125, 446.5, 309.0, 0, -2176, {"type": "adsb_icao", "flight": "DLH7YA", "squawk": "1000"}, "adsb_icao", 25875, -2208, 335, -10.7]] } ``` -------------------------------- ### Readsb Default Service Options Configuration Source: https://context7.com/wiedehopf/readsb/llms.txt Configuration options for readsb typically placed in /etc/default/readsb. This file allows for modular configuration of receiver, decoder, network, and JSON output settings. ```bash # /etc/default/readsb - Alternative configuration file RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain auto --ppm 0" DECODER_OPTIONS="--max-range 450 --write-json-every 1" NET_OPTIONS="--net --net-ri-port 30001 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005" JSON_OPTIONS="--json-location-accuracy 2 --range-outline-hours 24" ``` -------------------------------- ### Configure readsb network ports Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Sets up various network listening ports for readsb to broadcast different data formats (BEAST, SBS) to other applications or services. ```bash ./readsb --net-ri-port 30001 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005 ``` -------------------------------- ### Download Aircraft Database Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Downloads the aircraft database file required for mapping ICAO addresses to aircraft details. ```bash wget -O /usr/local/share/tar1090/aircraft.csv.gz https://github.com/wiedehopf/tar1090-db/raw/csv/aircraft.csv.gz ``` -------------------------------- ### Enable trace history in readsb Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Command-line option to enable the writing of flight path traces to a specified directory, which can then be served by a web server like Nginx for visualization. ```bash ./readsb --write-globe-history=/home/USER/readsb_history ``` -------------------------------- ### Profile readsb and Generate Flame Graph Source: https://github.com/wiedehopf/readsb/blob/dev/flamegraph.md This script records CPU stack traces for the readsb process using perf, then processes the output through stackcollapse and flamegraph scripts to generate an SVG visualization. It requires the perf tool, stackcollapse-perf.pl, and flamegraph.pl scripts to be available in the environment. ```bash #!/bin/bash perf record -F 99 --call-graph dwarf --pid $(pgrep -w -d ',' 'readsb') { timeout 120 ./perf.sh; }; sleep 2; perf script | ./stackcollapse-perf.pl --kernel | ./flamegraph.pl --width 1600 --bgcolors grey --cp > /opt/html/readsb.svg; echo; echo done ``` -------------------------------- ### Configure readsb Autogain Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Configures the software gain algorithm for rtl-sdr devices. The command allows tuning of noise and loudness thresholds to optimize ADS-B reception. ```bash --gain=auto-verbose,0,34,36,243 ``` -------------------------------- ### Beast Protocol Data Feeding Source: https://context7.com/wiedehopf/readsb/llms.txt Configuring output streams using the Beast protocol to feed data to external aggregators with optional filtering and bandwidth reduction. ```bash readsb --device-type rtlsdr --gain auto --net --quiet --net-connector feed.airplanes.live,30004,beast_reduce_plus_out,uuid=YOUR-UUID-HERE ``` -------------------------------- ### Configure Network-Only Data Source Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Configures readsb to operate in network-only mode, bypassing local SDR hardware and connecting to an external data source via TCP. ```bash RECEIVER_OPTIONS="--net-only --net-connector 192.168.2.7,30005,beast_in" ``` -------------------------------- ### Configure readsb JSON output Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Command-line arguments to configure readsb to periodically write aircraft data in JSON format to a specified directory, useful for web interfaces like tar1090. ```bash ./readsb --write-json-every 0.5 --write-json=~/tar1090/html/data/ ``` -------------------------------- ### Enable Globe History and Tracing Source: https://github.com/wiedehopf/readsb/blob/dev/README.md Configures readsb to write historical flight data and heatmaps to disk. This is typically used in conjunction with tar1090 for global map visualization. ```bash --write-globe-history /var/globe_history --heatmap 30 --json-trace-interval=0.1 ``` -------------------------------- ### JSON Output Version 2 Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Changes the JSON output syntax to be compatible with the adsbexchange v2 API. Timestamps are provided in milliseconds. ```url &jv2 ``` -------------------------------- ### Readsb Default Port Configuration Source: https://context7.com/wiedehopf/readsb/llms.txt Configures the default network ports for readsb services, including raw input/output, SBS output, Beast input/output, and API access. This allows readsb to communicate with other services and applications. ```bash readsb --device-type rtlsdr --gain auto --net \ --net-ri-port 30001 \ --net-ro-port 30002 \ --net-sbs-port 30003 \ --net-bi-port 30004,30104 \ --net-bo-port 30005 \ --net-beast-reduce-out-port 30006 \ --net-vrs-port 30007 \ --net-json-port 30008 \ --net-api-port 8042 ``` -------------------------------- ### Globe History and Trace Recording Source: https://context7.com/wiedehopf/readsb/llms.txt Enabling persistent storage of aircraft tracks, heatmap generation, and state persistence to maintain data across application restarts. ```bash readsb --device-type rtlsdr --gain auto --net --quiet --lat 51.5074 --lon -0.1278 --write-json /run/readsb --write-globe-history /var/globe_history --write-json-globe-index --heatmap 30 --json-trace-interval 30 --db-file /usr/local/share/tar1090/aircraft.csv.gz ``` -------------------------------- ### Find Aircraft by Identifiers Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Queries to find specific aircraft based on their Hex/ICAO ID, callsign, registration, or type code. ```url /?find_hex=,,.... ``` ```url /?find_callsign=,,..... ``` ```url /?find_reg=,,..... ``` ```url /?find_type=,,..... ``` -------------------------------- ### Fetch and Parse aircraft.json in Python Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md This script uses the urllib library to fetch data from a local readsb aircraft.json endpoint. It iterates through the aircraft list and prints the ICAO hex code along with the latitude and longitude for aircraft that have valid position data. ```python from contextlib import closing from urllib.request import urlopen, URLError import json url="http://192.168.2.14/tar1090/data/aircraft.json" with closing(urlopen(url, None, 5.0)) as aircraft_file: aircraft_data = json.load(aircraft_file) for a in aircraft_data['aircraft']: hex = a.get('hex') lat = a.get('lat') lon = a.get('lon') if lat and lon: print("Icao 24 bit id: {hex} Latitude: {lat:.4f} Longitude: {lon:.4f}".format(hex=hex, lat=lat, lon=lon)) ``` -------------------------------- ### Retrieve All Aircraft Data Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Queries to retrieve all aircraft data, with options to include only those with recent positions or all aircraft with recent messages. ```url /?all_with_pos ``` ```url /?all ``` -------------------------------- ### Nginx Configuration for Readsb API Proxy Source: https://context7.com/wiedehopf/readsb/llms.txt This Nginx configuration sets up a server to proxy API requests and serve static data for readsb. It configures upstream servers for Unix sockets, handles API endpoints, static JSON data, compressed trace files, globe history, and the tar1090 web interface. ```nginx # /etc/nginx/sites-available/readsb # Upstream for Unix socket upstream readsb_api { server unix:/run/readsb/api.sock; } server { listen 80; server_name adsb.example.com; # API endpoint location /re-api/ { gzip on; proxy_http_version 1.1; proxy_max_temp_file_size 0; proxy_set_header Connection $http_connection; proxy_set_header Host $http_host; proxy_pass http://unix:/run/readsb/api.sock:/$is_args$args; } # Static JSON data location /tar1090/data/ { alias /run/readsb/; add_header Cache-Control "no-cache"; # Compressed trace files location /tar1090/data/traces/ { gzip off; add_header Content-Encoding "gzip"; add_header Cache-Control "no-cache"; } } # Globe history data location /tar1090/globe_history/ { alias /var/globe_history/; gzip off; add_header Content-Encoding "gzip"; add_header Cache-Control "no-cache"; } # tar1090 web interface location /tar1090 { alias /usr/local/share/tar1090/html/; add_header Cache-Control "no-cache"; } } ``` -------------------------------- ### Network-Only Aggregation Source: https://context7.com/wiedehopf/readsb/llms.txt Configuring readsb to act as a network aggregator that receives data from remote receivers instead of local SDR hardware. ```bash readsb --net-only --net-connector 192.168.1.100,30005,beast_in --write-json /run/readsb --lat 51.5074 --lon -0.1278 ``` -------------------------------- ### Readsb Database Flags Interpretation (Python) Source: https://context7.com/wiedehopf/readsb/llms.txt Provides a Python function to interpret the bitfield `dbFlags` found in the aircraft JSON output. This helps in understanding aircraft properties like military status, interestingness, privacy, and LADD list inclusion. ```python def parse_db_flags(db_flags): military = (db_flags & 1) > 0 interesting = (db_flags & 2) > 0 pia = (db_flags & 4) > 0 # Privacy ICAO Address ladd = (db_flags & 8) > 0 # FAA LADD list return { 'military': military, 'interesting': interesting, 'pia': pia, 'ladd': ladd } ``` -------------------------------- ### Accessing Historical Flight Trace Data Source: https://context7.com/wiedehopf/readsb/llms.txt Information on accessing historical flight trace data, which provides a position history for flights. The trace files are organized by date and ICAO identifier in a specific directory structure. ```bash # Trace files are stored at: # /var/globe_history/traces/YYYY/MM/DD/trace_full_ICAO.json ``` -------------------------------- ### Filter by Database Flags Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Filters to include military aircraft, aircraft with PIA hex codes, or aircraft on the LADD list. These can be combined with OR logic. ```url &filter_mil ``` ```url &filter_pia ``` ```url &filter_ladd ``` -------------------------------- ### API Status Check Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md A simple query to check the status of the API server. A status code of 200 indicates normal operation. ```url ?status ``` -------------------------------- ### Interpreting readsb dbFlags Bitfield Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Demonstrates how to interpret the dbFlags bitfield to determine aircraft attributes like military status, interest level, PIA, and LADD. This requires bitwise AND operations. ```c military = dbFlags & 1; interesting = dbFlags & 2; PIA = dbFlags & 4; LADD = dbFlags & 8; ``` ```python military = dbFlags & 1 interesting = dbFlags & 2 PIA = dbFlags & 4 LADD = dbFlags & 8 ``` ```javascript let military = dbFlags & 1; let interesting = dbFlags & 2; let PIA = dbFlags & 4; let LADD = dbFlags & 8; ``` -------------------------------- ### Filter Options with readsb API Source: https://context7.com/wiedehopf/readsb/llms.txt Apply various filters to refine search results, including callsign (exact or prefix), squawk code, altitude range, military aircraft designation, and aircraft type. Filters can be combined with geographic queries. ```bash curl -sS 'http://localhost:8042/?all_with_pos&filter_callsign_exact=UAL123' | jq ``` ```bash curl -sS 'http://localhost:8042/?all_with_pos&filter_callsign_prefix=UAL' | jq ``` ```bash curl -sS 'http://localhost:8042/?all_with_pos&filter_squawk=7700' | jq ``` ```bash curl -sS 'http://localhost:8042/?all_with_pos&above_alt_baro=30000&below_alt_baro=40000' | jq ``` ```bash curl -sS 'http://localhost:8042/?all_with_pos&filter_mil' | jq ``` ```bash curl -sS 'http://localhost:8042/?box=40,42,-75,-73&filter_type=A320,A321' | jq ``` ```bash curl -sS 'http://localhost:8042/?circle=51.5074,-0.1278,100&filter_with_pos&below_alt_baro=10000' | jq ``` ```bash curl -sS 'http://localhost:8042/?all_with_pos&jv2' | jq ``` -------------------------------- ### Search Queries with readsb API Source: https://context7.com/wiedehopf/readsb/llms.txt Find specific aircraft using various identifiers such as ICAO hex code, callsign, registration, or aircraft type. Multiple values can be provided for most search parameters. ```bash curl -sS 'http://localhost:8042/?find_hex=A1B2C3,D4E5F6' | jq ``` ```bash curl -sS 'http://localhost:8042/?hexList=A1B2C3' | jq ``` ```bash curl -sS 'http://localhost:8042/?find_callsign=UAL123,DAL456' | jq ``` ```bash curl -sS 'http://localhost:8042/?find_reg=N12345,G-ABCD' | jq ``` ```bash curl -sS 'http://localhost:8042/?find_type=A320,B738,B77W' | jq ``` -------------------------------- ### Geographical Queries Source: https://github.com/wiedehopf/readsb/blob/dev/README-json.md Queries to retrieve aircraft within specific geographical areas. Options include circular, closest, and rectangular bounding boxes. ```url /?circle=,, ``` ```url /?closest=,, ``` ```url /?box=,,, ```