Ejemplo n.º 1
0
/* ===================================================================*/
void UserInit(void)
{
    UserDataInit();     /* Initialize user data. */
#if DEBUG
    printf("| -UserDataInit finished.\n");
    printf("|-+OnChipInit begins...\n");
#endif
    __DI();
    OnChipInit();       /* Initialize on-chip devices. */
    __EI();
#if DEBUG
    printf("| -OnChipInit finished.\n");
    printf("|-+PeripheralInit begins...\n");
#endif
    PeripheralInit();   /* Initialize peripheral devices. */
#if DEBUG
    printf("| -PeripheralInit finished.\n");
#endif
}
Ejemplo n.º 2
0
int main(int argc, char **argv) 
{
    int i;
    struct stat statInfo;
    struct sigaction act;
    extern void *Usb0IpWatchTask(void *);

    UNUSED_PARAM(argc);
    UNUSED_PARAM(argv);
    memset(&gEqptDescriptors, 0, sizeof(ReconnEqptDescriptors));

#ifndef __SIMULATION__
    initReconnCrashHandlers();
#endif
    memset(&act, 0, sizeof(act));
    act.sa_flags = SA_SIGINFO;
    act.sa_sigaction = reconnCleanUp;
    signal(SIGPIPE, SIG_IGN);
    sigaction(SIGTERM, &act, NULL);

    i = sizeof(reconnThreadIds);
    for(i = 0; i < RECONN_MAX_NUM_CLIENTS + RECONN_NUM_SYS_TASKS; i++)
    {
        reconnThreadIds[i] = -1;
    }
    for(i = 0; i < (RECONN_MAX_NUM_CLIENTS); i++)
    { 
        activeClientsList[i] = 0;
    }


    // If there is an upgrade in progress then start a task that will sleep for 10 minutes then run.
    // If the task wakes up, then the upgraded application has not crashed and so the new image 
    // is probably OK.
    if(stat(UPGRADE_INPROGRESS_FILE_NAME, &statInfo) == 0)
    {
        if( pthread_create(&(reconnThreadIds[RECONN_UPGRADE_CHECK_TASK]), NULL, upgradeCheckTask, (void *)0) < 0)
        {
            reconnDebugPrint("%s: Could not start upgradeCheckTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
        unlink(UPGRADE_INPROGRESS_FILE_NAME);
    }

    /*
     * Initialize the AVCOM crc routine. The crc is used for spectrum analyzer upgrade and firmware 
     * version intefaces.
     */
    crcInit();

    PeripheralInit();
//#ifdef DEBUG_CONNECT
    reconnDebugPrint("      gEqptDescriptors->powerMeterFd = %d\n", gEqptDescriptors.powerMeterFd);
    reconnDebugPrint("      gEqptDescriptors->dmmFd = %d\n", gEqptDescriptors.dmmFd);
    reconnDebugPrint("      gEqptDescriptors->analyzerFd = %d\n", gEqptDescriptors.analyzerFd);
//#endif
#ifndef __SIMULATION__
    //dmmDiags();
    dmmLoadSavedConfig();
#endif
    //
    // Startup debug menus
    //
    registerClientDebugMenu();
    registerFuelGaugeDebugMenu();
    registerSystemDebugMenu();
    registerDmmDebugMenu();
    registerSocketDebugMenu();
    registerRemoteMonDebugMenu();
    registerReconnMsgsMenu();

    if(pthread_create(&(reconnThreadIds[RECONN_MASTER_SOCKET_TASK]), NULL, insertedMasterTransmitTask, (void *)0) < 0)
    {
        reconnDebugPrint("%s: Could not start openInsertedMasterSocket %d %s\n", __FUNCTION__, errno, strerror(errno));
    }


    /*  Start up the command processing */
    if( pthread_create(&(reconnThreadIds[RECONN_EQPT_TASK]), NULL, reconnEqptTask, (void *)0) < 0)
    {
        reconnDebugPrint("%s: Could not start reconnEqptTask %d %s\n", __FUNCTION__, errno, strerror(errno));
    }
    else
    {
        if(pthread_create(&(reconnThreadIds[RECONN_PWR_MGMT_TASK]), NULL, reconnPwrMgmtTask, (void  *)&gEqptDescriptors) < 0)
        {
            reconnDebugPrint("%s: Could not start reconnPwrMgmtTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
        else if(pthread_create(&(reconnThreadIds[RECONN_EQPT_RSP_TASK]), NULL, reconnGetEqptResponseTask,(void *)&gEqptDescriptors) < 0)
        {
            reconnDebugPrint("%s: Could not start reconnGetEqptResponseTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
        else if(pthread_create(&(reconnThreadIds[RECONN_BATTERY_MONITOR_TASK]), NULL, reconnBatteryMonTask, (void *) 0 ) < 0)
        {
            reconnDebugPrint("%s: Could not start reconnBatteryMonTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
        else if(pthread_create(&(reconnThreadIds[RECONN_DEBUG_MENU_TASK]), NULL, debugMenuTask, (void *) 0 ) < 0)
        {
            reconnDebugPrint("%s: Could not start debugMenuTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
        else if(pthread_create(&(reconnThreadIds[RECONN_POWER_METER_TASK]), NULL, powerMeterPresenceTask, (void *) &gEqptDescriptors) < 0)
        {
            reconnDebugPrint("%s: Could not start powerMeterPresenceTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
//#ifndef __SIMULATION__
        else if(pthread_create(&(reconnThreadIds[RECONN_DMM_SAVE_CONFIG_TASK]), NULL, dmmSaveConfigTask, (void *) 0 ) < 0)
        {
            reconnDebugPrint("%s: Could not start dmmSaveConfigTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
        }
//#endif
        else
        {
#ifndef __SIMULATION__
            //
            // Need to register with libiphoned. This callback will signal when
            // the iphone has been inserted into the reconn toolkit.
            //
            libiphoned_register_presence_change_callback(reconnMasterIphone);
            libiphoned_register_rx_callback(insertedMasterRead, RECONN_RSP_PAYLOAD_SIZE);

            //
            // Now start libiphoned. This is a daemon which does all of the "heavy lifting" for the 
            // front panel iPhone. The daemon does the reading, writing, insertion, and iPhone extraction.
            //
            reconnDebugPrint("%s: Calling libiphoned_start()\n", __FUNCTION__);
            if(libiphoned_start() == -1)
            {
                reconnDebugPrint("%s: libiphoned_start() failed\n", __FUNCTION__);
                exit(0);
            }

            /*
             * Now that the embedded software is up and running, stop the power LED from flashing.
             */
            if(reconnGpioAction(POWER_LED_GPIO, ENABLE, NULL) != RECONN_SUCCESS)
            {
                reconnDebugPrint("%s: reconnGpioAction(POWER_LED_GPIO, ENABLE, NULL) failed.\n", __FUNCTION__);
            }
#endif
            wifiStartConnectionTask();
#ifndef __SIMULATION__
            if(pthread_create(&(reconnThreadIds[RECONN_IP_WATCH_TASK]), NULL, Usb0IpWatchTask, (void *)0) < 0)
            
            {
                reconnDebugPrint("%s: Could not start Usb0IpWatchTask, %d %s\n", __FUNCTION__, errno, strerror(errno));
            }
#endif
        }
    }

    /*
     * See if we should start the task that accepts Wifi connections.
     */ 
    pthread_join(reconnThreadIds[RECONN_POWER_METER_TASK], NULL);
    reconnDebugPrint("%s: Exiting *******************\n",__FUNCTION__);
    exit (0);
}