Ejemplo n.º 1
0
bool AP_Arming::arm_checks(ArmingMethod method)
{
    // ensure the GPS drivers are ready on any final changes
    if ((checks_to_perform & ARMING_CHECK_ALL) ||
        (checks_to_perform & ARMING_CHECK_GPS_CONFIG)) {
        if (!AP::gps().prepare_for_arming()) {
            return false;
        }
    }

    // check system health on arm as well as prearm
    if ((checks_to_perform & ARMING_CHECK_ALL) ||
        (checks_to_perform & ARMING_CHECK_SYSTEM)) {
        if (!system_checks(true)) {
            return false;
        }
    }
    
    // note that this will prepare DataFlash to start logging
    // so should be the last check to be done before arming
    if ((checks_to_perform & ARMING_CHECK_ALL) ||
        (checks_to_perform & ARMING_CHECK_LOGGING)) {
        DataFlash_Class *df = DataFlash_Class::instance();
        df->PrepForArming();
        if (!df->logging_started()) {
            check_failed(ARMING_CHECK_LOGGING, true, "Logging not started");
            return false;
        }
    }
    return true;
}
Ejemplo n.º 2
0
bool AP_Arming::pre_arm_checks(bool report)
{
#if !APM_BUILD_TYPE(APM_BUILD_ArduCopter)
    if (armed || require == NO) {
        // if we are already armed or don't need any arming checks
        // then skip the checks
        return true;
    }
#endif

    return hardware_safety_check(report)
        &  barometer_checks(report)
        &  ins_checks(report)
        &  compass_checks(report)
        &  gps_checks(report)
        &  battery_checks(report)
        &  logging_checks(report)
        &  manual_transmitter_checks(report)
        &  servo_checks(report)
        &  board_voltage_checks(report)
        &  system_checks(report);
}
Ejemplo n.º 3
0
Archivo: start.c Proyecto: TrTLE/core
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
{
    sal_Bool bSentArgs = sal_False;
    const char* pUsePlugin;
    rtl_uString *pPipePath = NULL;
    Args *args;
    int status = 0;
    struct splash* splash = NULL;
    struct sigaction sigpipe_action;
    struct sigaction sigterm_action;

    /* turn SIGPIPE into an error */
    memset(&sigpipe_action, 0, sizeof(struct sigaction));
    sigpipe_action.sa_handler = SIG_IGN;
    sigemptyset(&sigpipe_action.sa_mask);
    sigaction(SIGPIPE, &sigpipe_action, NULL);
    memset(&sigterm_action, 0, sizeof(struct sigaction));
    sigterm_action.sa_handler = &sigterm_handler;
    sigemptyset(&sigterm_action.sa_mask);
    sigaction(SIGTERM, &sigterm_action, NULL);

    args = args_parse ();
    args->pAppPath = get_app_path( argv[0] );
    if ( !args->pAppPath )
    {
        fprintf( stderr, "ERROR: Can't read app link\n" );
        exit( 1 );
    }

#ifndef ENABLE_QUICKSTART_LIBPNG
    /* we can't load and render it anyway */
    args->bInhibitSplash = sal_True;
#endif

    pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" );
    if ( pUsePlugin && !strcmp(pUsePlugin, "svp") )
        args->bInhibitSplash = sal_True;

    if ( !args->bInhibitPipe && getenv("LIBO_XDGAPP") == NULL )
    {
        int fd = 0;
        pPipePath = get_pipe_path( args->pAppPath );

        if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
        {
            // Wait for answer
            char resp[ strlen( "InternalIPC::SendArguments" ) + 1];
            ssize_t n = read( fd, resp, SAL_N_ELEMENTS( resp ) );
            if (n == (ssize_t) SAL_N_ELEMENTS( resp )
                && (memcmp(
                resp, "InternalIPC::SendArguments",
                SAL_N_ELEMENTS( resp ) - 1) == 0)) {
                rtl_uString *pCwdPath = NULL;
                osl_getProcessWorkingDir( &pCwdPath );

                // Then send args
                bSentArgs = send_args( fd, pCwdPath );
           }

            close( fd );
        }
    }

    if ( !bSentArgs )
    {
        /* we have to prepare for, and exec the binary */
        int nPercent = 0;
        ChildInfo *info;
        sal_Bool bAllArgs = sal_True;
        sal_Bool bShortWait, bRestart;

        /* sanity check pieces */
        system_checks();

        /* load splash image and create window */
        if ( !args->bInhibitSplash )
        {
            splash = splash_create(args->pAppPath, argc, argv);
        }

        /* pagein */
        if (!args->bInhibitPagein)
            exec_pagein (args);

        /* javaldx */
#if HAVE_FEATURE_JAVA
        if (!args->bInhibitJavaLdx)
            exec_javaldx (args);
#endif

        do
        {
            bRestart = sal_False;

            /* fast updates if we have somewhere to update it to */
            bShortWait = splash ? sal_True : sal_False;

            /* Periodically update the splash & the percent according
               to what status_fd says, poll quickly only while starting */
            info = child_spawn (args, bAllArgs, bShortWait);
            g_pProcess = info->child;
            while (!child_exited_wait (info, bShortWait))
            {
                ProgressStatus eResult;

                splash_draw_progress( splash, nPercent );
                eResult = read_percent( info, &nPercent );
                if (eResult != ProgressContinue)
                {
                    splash_destroy(splash);
                    splash = NULL;
                    bShortWait = sal_False;
                }

            }


            status = child_get_exit_code(info);
            g_pProcess = NULL; // reset
            switch (status) {
            case EXITHELPER_CRASH_WITH_RESTART: // re-start with just -env: parameters
                bRestart = sal_True;
                bAllArgs = sal_False;
                break;
            case EXITHELPER_NORMAL_RESTART: // re-start with all arguments
                bRestart = sal_True;
                bAllArgs = sal_True;
                break;
            default:
                break;
            }

            child_info_destroy (info);
        } while (bRestart);
    }

    /* cleanup */
    if ( pPipePath )
        rtl_uString_release( pPipePath );
    args_free (args);

    return status;
}