mode-s-decoder
A library to decode a binary Mode S message to an easy to use JavaScript object.
Mode S is an aviation transponder interrogation mode used by Secondary Surveillance Radar (SSR) and Automatic Dependent Surveillance-Broadcast (ADS-B) systems.
For an example of this module in use, see AirplaneJS.
Installation
npm install mode-s-decoder --save
Usage
const Decoder = const decoder = const data = 0x8f 0x46 0x1f 0x36 0x60 0x4d 0x74 0x82 0xe4 0x4d 0x97 0xbc 0xd6 0x4econst message = decoder console
API
Decoder.UNIT_FEET
A constant indicating that the unit used is feet. Used to check the unit
of the message using the message.unit
property.
Decoder.UNIT_METERS
A constant indicating that the unit used is meters. Used to check the
unit of the message using the message.unit
property.
decoder = new Decoder([options])
Initialize a new decoder object.
Arguments:
options
- An optional options object
The available options are:
fixErrors
- Set tofalse
to disable automatic error correction (default:true
)aggressive
- Set totrue
to enable aggressive error correction algorithm. Only used iffixErrors
istrue
(default:false
)
message = decoder.parse(data[, crcOnly])
Parse a binary Mode S message into an easy to use JavaScript object.
Arguments:
data
- A binary Mode S message (e.g. a Buffer or Uint8Array object)crcOnly
- Optional boolean indicating if the decoder should only validate the checksum. Iftrue
, the returnedmessage
object will only contain the propertiesmsg
,msgtype
,msgbits
,crc
, andcrcOk
(default:false
)
Returns a message
object containing the decoded message.
It's recommended to use this module together with the mode-s-aircraft-store module. This allows you easy access to the decoded latitude and longitude as this information cannot be read from a single Mode S message, but needs multiple concurrent messages in order to be properly decoded:
const message = decoder // store is an instance of AircraftStore from the mode-s-aircraft-store modulestore // ... // later after storing multiple messages, output list of aircrafts:store
License
MIT