Searching, please wait...

libhomeradar

easy collect aircraft information
~50,000,000 registered contacts
303894 unique aircraft records, 28.78% unresolved records
 ACARS DECODER Planespotting Network Kinetic Avionics AirNav Systems Airframes.org Atlas Tracking
libhomeradar - easy collect aircraft informations

libhomeradar is an easy to use library for all type of programming language which can use libraries. libhomeradar can connect to different sources to collect aircraft informations arround the world with extended informations, powerful filtering and structured data access.

libhomeradar is written in C and is available for Linux and Windows (2003, XP, NT, Vista).

Currently libhomeradar works with the Kinetic Avionics SBS-1 base station and the Airnav Systems Radarbox.


Yahoo! My Web  Google Bookmarks  Windows Live  Facebook  Ask  del.icio.us  Furl 
 

With this example we will not add any hosts. We try to connect to a running libhomeradar instance which have a listener on port 10000 installed. (See example #13). The mode is LHR_POLL (active mode, we read the messages from the open socket).


 
libhomeradar - easy collect aircraft informations - Download example  Download this source
/* System includes */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

/* libhomeradar header include */
#include "libhomeradar.h"

/* Global variable to libhomeradar */
LHR H = NULL;

/* Callback function to show aircraft informations */
void newcontact(void *handle,const int *id, LHR_CONTACT *C) {
  LHR_AIRPORTS *P;

  printf("%sContact: %s [%s]\nAirline: %s\nFlightnumber: %s  Callsign: %s\nSquawk: %04d\n",
         (C->newcontact)?"AIR":"",
          C->icao24,(C->reg)?C->reg:"UNKNOWN",
         (C->airline)?C->airline:"NULL",C->flightnum,C->callsign,C->squawk);
  printf("Aircraft: %s %s [%s] cn:%s\n",C->manufacturer,C->model,C->details,C->cn);
  printf("Routing: %s LAT: %0.5f LON: %0.5f\n",(C->route)?C->route:"UNKNOWN",C->lat,C->lon);

  /* Get airport informations */
  P = C->airports;
  while (P) {
    if (P->airport) {
      printf("Airport [%s / %s] Name: %s, %s\n",
             P->airport->iata,P->airport->icao,
             P->airport->name,P->airport->country);
    } else printf("Unresolveable: %s\n",P->apcode);
    P = P->next;
  }

  printf("..F..\n");

  /* Free LHR_CONTACT struct */
  homeradar_freecontact(C);
}

/* Callback function to show aircraft informations */
void newcontactRB(void *handle,const int *id, LHR_CONTACT *C) {

  /* Show only ICAO24 and registration */
  printf("[RADARBOX]\n%sContact: %s [%s]\n",(C->newcontact)?"AIR":"",
          C->icao24,(C->reg)?C->reg:"UNKNOWN");

  /* Free LHR_CONTACT struct */
  homeradar_freecontact(C);
}

/* Shutdown library and finish program */
void shutdownlib(int sig) {

  printf("Shutdown system. Closing library handle...\n");

  /* Close lib handle */
  if (H) homeradar_destroy(H);
  exit(0);
}

/* Main program */
int main(int argc, char **argv) {
  int e, h;

  /* Init global variable */
  H = homeradar_init(16,LHR_AUTOCONNECT|LHR_LOOKUP_ALL,&e,NULL);

  /* No error */
  if (H == NULL) {
    printf("Error initializing libhomeradar. Errorcode #%d\n",e);
    return 255;
  }

  /* Catch SIGINT signals (CTRL-C) */
  (void)signal(SIGINT, shutdownlib);

  /* Load databases from disc
     Files should be located within the current directory */
  homeradar_load_databases(H, "./");

  /* Create listener for external socket connects */
  if (!(h = homeradar_socketinput(H, 1, LHR_POLL, 10000, "localhost")))
    printf("Unable to create connection to localhost on port 10000\n");

  /* Setup the event listener for the LHR_ONCONTACT event */
  if (homeradar_onhandler(H, LHR_ONCONTACT, h, newcontact)==0)
    printf("Unable to add event listener (1)\n");

  /* Do nothing - in this example - loop will be finished after 5 minutes
     In your real program you can do now what you want */
  sleep(300);

  /* Destroy lib handler */
  homeradar_destroy(H);

  /* Return success */
  return 0;
}