/* * PMAPI context creation and initial command line option handling. */ static int setup_context(pmOptions *opts) { char *source; int sts, ctx; if (opts->context == PM_CONTEXT_ARCHIVE) source = opts->archives[0]; else if (opts->context == PM_CONTEXT_HOST) source = opts->hosts[0]; else if (opts->context == PM_CONTEXT_LOCAL) source = NULL; else { opts->context = PM_CONTEXT_HOST; source = "local:"; } if ((sts = ctx = pmNewContext(opts->context, source)) < 0) { if (opts->context == PM_CONTEXT_HOST) pmprintf( "%s: Cannot connect to pmcd on host \"%s\": %s\n", pmProgname, source, pmErrStr(sts)); else if (opts->context == PM_CONTEXT_LOCAL) pmprintf( "%s: Cannot make standalone connection on localhost: %s\n", pmProgname, pmErrStr(sts)); else pmprintf( "%s: Cannot open archive \"%s\": %s\n", pmProgname, source, pmErrStr(sts)); } else if ((sts = pmGetContextOptions(ctx, opts)) == 0) sts = setup_origin(opts); if (sts < 0) { pmflush(); cleanstop(1); } return ctx; }
void dcm_callback_gps_location_updated(void) { if (state_flags._.save_origin) { // capture origin information during power up. much of this is not // actually used for anything, but is saved in case you decide to // extend this code. state_flags._.save_origin = 0; setup_origin(); #if (BAROMETER_ALTITUDE == 1) altimeter_calibrate(); #endif } // Ideally, navigate should take less than one second. // For MatrixPilot, navigation takes only a few milliseconds. // If you rewrite navigation to perform some rather ambitious calculations, // perhaps using floating point, matrix inversions, Kalman filters, etc, // you will not cause a stack overflow if you take more than 1 second, // the interrupt handler will simply skip some of the navigation passes. }