sbs

package module
v0.0.0-...-7738474 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2020 License: BSD-3-Clause Imports: 4 Imported by: 1

README

What?

go-sbs provides a parser for SBS-1 CSV format data otherwise known as "SBS-1 BaseStation Port 30003" format.

The SBS-1 data format was developed, it seems, by Kinetic Avionics Limited for the BaseStation SDR product. This library, like pretty much every other, takes most of its understanding of the data format from http://woodair.net/SBS/Article/Barebones42_Socket_Data.htm

The dump1090 bits come from code diving dump1090-fa, the actively maintained (but not very well documented imnsho) fork of dump1090 by FlightAware. https://github.com/flightaware/dump1090

Support / Contributing

I'm putting this up on the public interwebs because I couldn't find such a thing when I needed it. Maybe it'll help you out in a moment of darkness. Because, really, who has time to figure out this weird CSV? Well, me, for a bit.

This is a personal side project and will get about that much attention, maybe less. Feel free to file issues but I make no promise as to when I'll get to them. I'm not real keen on pull requests because I don't really have time to do proper reviews. But, feel free to fork the code, respecting the license, and have your way with it.

License

Copyright Matt Cashner (sungo)

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Overview

Package sbs provides a parser for SBS-1 CSV format data otherwise known as "SBS-1 BaseStation Port 30003" format.

The SBS-1 data format was developed, it seems, by Kinetic Avionics Limited for the BaseStation SDR product. This library, like pretty much every other, takes most of its understanding of the data format from http://woodair.net/SBS/Article/Barebones42_Socket_Data.htm

The dump1090 bits come from code diving dump1090-fa, the actively maintained (but not very well documented imnsho) fork of dump1090 by FlightAware. https://github.com/flightaware/dump1090

This code is copyright Matt Cashner (sungo). Licensed under BSD-3-Clause.

Index

Constants

View Source
const (
	// SelectionChange is message type "SEL", aka "Selection Change",
	// "generated when the user changes the selected aircraft". This field is
	// specific to the BaseStation software and not used by dump1090-fa
	SelectionChange = iota

	// NewID is message type "ID", aka "Mew ID Message", "generated when
	// an aircraft being tracked sets or changes its callsign". Unused by
	// dump1090-fa
	NewID

	// NewAircraft is message type "AIR", aka "New Aircraft Message",
	// "generated when a signal is picked up for a previously untracked
	// aircraft". Unused by dump1090-fa
	NewAircraft

	// StatusChange is message type "STA", aka "Status Change Message",
	// "generated when an aircraft's status changes". Unused by dump1090-fa
	StatusChange

	// Click is message type "CLK", aka "Click Message", used by
	// BaseStation to indicate a user clicked on an aircraft. Unused by
	// dump1090-fa
	Click

	// Transmission is message type "MSG", aka "Transmission Message",
	// generated by the aircraft.
	Transmission
)

These constants correspond to different Message Types

View Source
const (

	// ESIdentify is TransmissionType "ES Identification and Category"
	ESIdentify

	// ESSurfacePosition is TransmissionType "ES Surface Position Message",
	// "triggered by nose gear squat switch"
	ESSurfacePosition

	// ESAirbornePosition is TransmissionType "ES Airborne Position Message"
	ESAirbornePosition

	// ESAirborneVelocity is TransmissionType "ES Airborne Velocity Message"
	ESAirborneVelocity

	// SurveillanceAlt is TransmissionType "Surveillance Alt Message",
	// "triggered by ground radar"
	// Will only be output if the aircraft has previously sent ESIdentify,
	// ESSurfacePosition, ESAirbornePosition, ESAirborneVelocity, or
	// AllCallReply
	SurveillanceAlt

	// SurveillanceID is TransmissionType "Surveillance ID Message", "triggered
	// by ground radar", Will only be output if the aircraft has previously
	// sent ESIdentify, ESSurfacePosition, ESAirbornePosition,
	// ESAirborneVelocity, or AllCallReply
	SurveillanceID

	// AirToAir is TransmissionType "Air to Air Message", "triggered from TCAS"
	AirToAir

	// AllCallReply is TransmissionType "All Call Reply", "broadcast but also
	// triggered by ground radar"
	AllCallReply
)

These constants correspond to different Transmission Types

View Source
const Unknown = -1

Unknown indicates an unknown value. Used in both MessageType, and TransmissionType fields

Variables

This section is empty.

Functions

This section is empty.

Types

type SBS

type SBS struct {
	MessageType      int
	TransmissionType int
	SessionID        int       // With dump1090, this is always 1
	AircraftID       int       // With dump1090, this is always 1
	HexIdent         string    // Aircraft Mode S hexadecimal code
	FlightID         int       // With dump1090, this is always 1
	TimeGenerated    time.Time // Protocol does not contain timezone data
	TimeLogged       time.Time // Protocol does not contain timezone data

	CallSign          string // Eight digit flight ID. Can be anything at all
	Altitude          int    // Mode C altitude. Height relative to 1013.2mb (Flight Level). Not height AMSL.
	GroundSpeed       float64
	Track             float64 // In dump1090, this is the aircraft's heading. Elsewhere, the track of the craft derived from the velocity E/W and velocity N/S
	Latitude          float64
	Longitude         float64
	VerticalRate      int
	Squawk            string  // Assigned Mode A Squawk code
	SquawkChangeAlert Trinary // Flag to indicate the squawk has changed
	Emergency         Trinary // Flag to indicate the emergency code has been set
	SPI               Trinary // Flag to indicate the transponder ident has been activated
	IsOnGround        Trinary // Flag to indicate the ground squat switch is active
}

SBS represents a single SBS-1 datagram

func Parse

func Parse(input string) (SBS, error)

Parse takes an SBS-1 CSV string and converts it to an SBS struct

func (*SBS) MessageTypeAsString

func (s *SBS) MessageTypeAsString() string

MessageTypeAsString renders the MessageType field in a human-friendly string

func (*SBS) TransmissionTypeAsString

func (s *SBS) TransmissionTypeAsString() string

TransmissionTypeAsString converts the TransmissionType field into a human-friendly string

type Trinary

type Trinary struct {
	IsSet bool // Was the value set in the data stream?
	Value bool // Only useful if IsSet is true
}

Trinary is a bit of an obnoxious hack. The data specification contains several fields that can be true, false, or "not set".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL