moxon-frame-generator
simple generator for 3D-printed frames for a moxon rectangle antenna
A Mode S / ADS-B decoder library
git clone https://github.com/watson/libmodes.gitwatson/libmodesThis is a C library for decoding Mode S messages from aviation aircrafts. It supports both standard Mode S Acquisition Squitter messages (56 bits) and Mode S Extended Squitter messages (112 bits) that also carry ADS-B information.
This project is a refactoring of the popular dump1090 project by Salvatore Sanfilippo. It modularizes the code into separate functions and removes all non-essentials, so that only the decoding logic is left.
#include "mode-s.h"
#include <stdio.h>
void on_msg(mode_s_t *self, struct mode_s_msg *mm) {
printf("Got message from flight %s at altitude %d\n", mm->flight, mm->altitude);
}
int main(int argc, char **argv) {
mode_s_t state;
uint32_t data_len = 262620;
unsigned char data[data_len];
uint16_t mag[data_len / 2];
// initialize the decoder state
mode_s_init(&state);
// get some raw IQ data somehow
get_samples(&data);
// compute the magnitude of the signal
mode_s_compute_magnitude_vector(&data, &mag, data_len);
// detect Mode S messages in the signal and call on_msg with each message
mode_s_detect(&state, &mag, data_len/2, on_msg);
}
Check out
tests/test.c
for a complete example.
The provided callback to mode_s_detect will be called with a
mode_s_msg struct. This struct contain the following fields:
unsigned char msg[14] - Binary messageint msgbits - Number of bits in messageint msgtype - Downlink format #int crcok - True if CRC was validuint32_t crc - Message CRCint errorbit - Bit corrected. -1 if no bit correctedint aa1 - ICAO Address byte 1int aa2 - ICAO Address byte 2int aa3 - ICAO Address byte 3int phase_corrected - True if phase correction was appliedint ca - Responder capabilitiesint metype - Extended squitter message typeint mesub - Extended squitter message subtypeint heading_is_validint headingint aircraft_typeint fflag - 1 = Odd, 0 = Even CPR messageint tflag - UTC synchronized?int raw_latitude - Non decoded latitudeint raw_longitude - Non decoded longitudechar flight[9] - 8 chars flight numberint ew_dir - 0 = East, 1 = Westint ew_velocity - E/W velocityint ns_dir - 0 = North, 1 = Southint ns_velocity - N/S velocity.int vert_rate_source - Vertical rate sourceint vert_rate_sign - Vertical rate signint vert_rate - Vertical rateint velocity - Computed from EW and NS velocityint fs - Flight status for DF4, 5, 20, 21int dr - Request extraction of downlink requestint um - Request extraction of downlink requestint identity - 13 bits identity (Squawk)int altitudeint unitTo test the library, simply run:
make && make test
Note that the first time you run make test, a large (ca. 50MB) test
fixture will be downloaded to tests/fixtures. You can delete this
folder at any time if you wish.
BSD-2-Clause
more like this
simple generator for 3D-printed frames for a moxon rectangle antenna
search projects, people, and tags