Exemple #1
0
GameMode::GameMode():
  doc_objects(NULL),
  weapons_xml(NULL)
{
  m_current = "classic";

  LoadDefaultValues();
}
Exemple #2
0
bool GameMode::Load(void)
{
  Config * config = Config::GetInstance();
  m_current = config->GetGameMode();

  LoadDefaultValues();

  // Game mode objects configuration file
  if (!doc_objects->Load(GetObjectsFilename()))
    return false;

  if (!doc.Load(GetFilename()))
    return false;
  if (!LoadXml())
    return false;

  return true;
}
Exemple #3
0
// Load the game mode from strings (probably from network)
bool GameMode::LoadFromString(const std::string& game_mode_name,
                              const std::string& game_mode_contents,
                              const std::string& game_mode_objects_contents)
{
  m_current = game_mode_name;
  MSG_DEBUG("game_mode", "Loading %s from network: ", m_current.c_str());
  LoadDefaultValues();

  if (!doc_objects->LoadFromString(game_mode_objects_contents))
    return false;

  if (!doc.LoadFromString(game_mode_contents))
    return false;
  if (!LoadXml())
    return false;

  MSG_DEBUG("game_mode", "OK\n");
  return true;
}
void UserInit(void){
	//setPrintStream(&USBPutArray);
	setPrintLevelInfoPrint();
	println_I("\n\nStarting PIC initialization");
	//DelayMs(1000);
	hardwareInit();
	println_I("Hardware Init done");

	ReleaseAVRReset();



	CheckRev();

	LoadEEstore();

	LoadDefaultValues();

	CartesianControllerInit();

	InitPID();

	UpdateAVRLED();


	lockServos();
	setPrintLevelInfoPrint();

	BOOL brown = getEEBrownOutDetect();
	setCoProcBrownOutMode(brown);
	setBrownOutDetect(brown);


	println_I("###Starting PIC In Debug Mode###\n");// All printfDEBUG functions do not need to be removed from code if debug is disabled
	DelayMs(1000);
	//setPrintLevelErrorPrint();
	println_E("Error level printing");
	println_W("Warning level printing");
	println_I("Info level printing");
}
Exemple #5
0
//*****************************************************************************
//
//! main - populate the parameters from predefines Test Vector or User
//!
//! \param None
//!
//! \return None
//
//*****************************************************************************
void
main()
{
    unsigned int uiConfig,uiHashLength,uiDataLength;
    unsigned char *puiKey1,*puiData,*puiResult;
    unsigned int u8count;
#ifndef USER_INPUT
    unsigned char *puiTempExpResult;
#endif
    //
    // Initialize board configurations
    BoardInit();
    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    //
    // Enable the module .
    //
    MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK);
    //
    // Enable interrupts.
    //
    MAP_SHAMD5IntRegister(SHAMD5_BASE, SHAMD5IntHandler);

#ifdef USER_INPUT
    while(FOREVER)
    {
        //
        // Read values either from User or from Vector based on macro USER_INPUT
        // defined or not
        //

        //
        // Read the values from the user over uart and Populate the variables
        //
        puiData=ReadFromUser(&uiConfig,&uiHashLength,&puiKey1,&uiDataLength,
                             &puiResult);
        if(puiData==NULL)
        {
            continue;
        }
#else
    //
    // Load Default values
    //
    UART_PRINT("Running Keyed Hashing HMAC_MD5\n\r\n\r");
    UART_PRINT("loading default values\n\r\n\r");
    uiHMAC=1;
    puiData= LoadDefaultValues(SHAMD5_ALGO_HMAC_MD5,&uiConfig,&uiHashLength,
                               &puiKey1,&uiDataLength,&puiResult);
    UART_PRINT("Data Length (in Bytes) %d\n\r\n\r",uiDataLength);
#endif

        //
        // Generate Hash Value
        //
        UART_PRINT("\n\rHashing in Progress... \n\r");
        GenerateHash(uiConfig,puiKey1,puiData,puiResult,uiDataLength);
        UART_PRINT("Hash Value is generated\n\r");
        //
        // Display/Verify Result
        //

#ifdef USER_INPUT
        //
        // Display Hash Value Generated
        //
        UART_PRINT("\n\r The Hash Value in Hex is: 0x%02x",*puiResult);
        for(u8count=0; u8count<(uiHashLength/4); u8count++)
        {
            UART_PRINT("%02x",*(puiResult+u8count));
        }
        UART_PRINT("\n\r");
    } //end while(FOREVER)
#else
        //
        // Comapre Hash Generated and expected values from predefined vector
        //
        UART_PRINT("Hash Length (in Bytes) %d\n\r\n\r",uiHashLength);
        UART_PRINT("\n\r Computed Hash Value in Hex is: ");
        for(u8count=0; u8count<uiHashLength; u8count++)
        {
            UART_PRINT("%02x",*(puiResult+u8count));
        }
        UART_PRINT("\n\r");

        puiTempExpResult = (unsigned char *)g_psHMACShaMD5TestVectors.puiExpectedHash;

        UART_PRINT("\n\r Expected Hash Value in Hex is: ");
        for(u8count=0; u8count<uiHashLength; u8count++)
        {
            UART_PRINT("%02x",*(puiTempExpResult+u8count));
        }
        UART_PRINT("\n\r");

        if(memcmp(puiResult,g_psHMACShaMD5TestVectors.puiExpectedHash,uiHashLength)==0)
        {
            UART_PRINT("\n\r Hashing verified successfully");
        }
        else
        {
            UART_PRINT("\n\r Error in Hashing computation");
        }
        while(FOREVER);
#endif


}
Exemple #6
0
//*****************************************************************************
//
//! main - calls Crypt function after populating either from pre- defined vector 
//! or from User
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void 
main()
{
    unsigned int uiConfig,uiKeySize,*puiKey1,*puiData,*puiResult=NULL,
    uiDataLength,uiIV[4]={0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c};

#ifdef USER_INPUT
    unsigned int uiCharCount;
    unsigned char* pucResult;
#else
    unsigned int *puiIV;
    puiIV=&uiIV[0];

#endif
    BoardInit();
    
    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    //
    // Enable AES Module
    //
    MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK);
    
    //
    // Enable AES interrupts.
    //
    MAP_AESIntRegister(AES_BASE, AESIntHandler);
#ifdef USER_INPUT
    while(FOREVER)
    {
        //
        // Read values either from User or from Vector based on macro USER_INPUT
        // defined or not
        //

        //
        // Read the values from the user over uart and Populate the variables
        //
        puiData = ReadFromUser(&uiConfig,&uiKeySize,&puiKey1,&uiDataLength,\
                                &puiResult);
        if((puiData == NULL) || (puiResult == NULL))
        {
            continue;
        }
#else
        //
        // Load Default values
        //
        puiData = LoadDefaultValues(AES_CFG_DIR_ENCRYPT | AES_CFG_MODE_CBC ,
                                    &uiConfig,&uiKeySize,&puiIV,&puiKey1,
                                    &uiDataLength,&puiResult);
        
        if((puiData == NULL) || (puiResult == NULL))
        {
            while(FOREVER);
        }
#endif

        //
        // Carry out Encryption
        //
        UART_PRINT("\n\r Encryption in progress....");
        AESCrypt(uiConfig,uiKeySize,puiKey1,puiData,puiResult,uiDataLength,uiIV);
        UART_PRINT("\n\r Encryption done, cipher text created");
        
        //
        // Copy Result into Data Vector to continue with Decryption. and change 
        // config value
        //
        memcpy(puiData,puiResult,uiDataLength);
        uiConfig &= ~(1 << 2);
        //
        // Carry out Decryption
        //
        UART_PRINT("\n\r\n\r Decryption in progress....");
        AESCrypt(uiConfig,uiKeySize,puiKey1,puiData,puiResult,uiDataLength,uiIV);
        UART_PRINT("\n\r Decryption done");
        
        //
        // Display/Verify Result
        //

    #ifdef USER_INPUT
        //
        // Display Plain Text
        //
        UART_PRINT("\n\r Text after decryption ");
        pucResult = (unsigned char *)puiResult;
        for(uiCharCount=0;uiCharCount<uiDataLength;uiCharCount++)
        {
            UART_PRINT("%c",*(pucResult+uiCharCount));
        }
        UART_PRINT("\n\r");
        if(puiResult)
        {
        	free(puiResult);
        }
        if(puiData)
        {
        	free(puiData);
        }
    }
    #else
        //
        // Compare Cipher Text and Plain Text with the expected values from 
        // predefined vector
        //
        if(memcmp(puiData,psAESCBCTestVectors.pui32CipherText,
                        psAESCBCTestVectors.ui32DataLength)==0)
        {
            UART_PRINT("\n\r\n\r Encryption verification Successful");
        }
        else
        {
            UART_PRINT("\n\r\n\r Error in Encryption");
        }

        if(memcmp(puiResult,psAESCBCTestVectors.pui32PlainText,
                        psAESCBCTestVectors.ui32DataLength)==0)
        {
            UART_PRINT("\n\r Decryption verification Successful");
        }
        else
        {
            UART_PRINT("\n\r\n\r Error in Decryption");
        }
        while(FOREVER);
    #endif

}
Renderer::Renderer():distortion_enabled(false),DistortionPath(DISTORTION_PATH){
    LoadDefaultValues();
    SetIdentity(matrix);
}
void hardwareInit() {


    // Configure the device for maximum performance but do not change the PBDIV
    // Given the options, this function will change the flash wait states, RAM
    // wait state and enable prefetch cache but will not change the PBDIV.
    // The PBDIV value is already set via the pragma FPBDIV option above..
    SYSTEMConfig((80000000L), SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
    SYSTEMConfigPerformance(80000000);
    CHECONbits.PREFEN = 0;


    int j = 0, i = 0;

    for (i = 0; i < 6; i++) {
        MyMAC.v[i] = MY_MAC_ADDRESS[i];
    }
    StartCritical();

    println_I("MAC");
    enableFlashStorage(true);
    FlashGetMac(MyMAC.v);

    for (i = 0; i < 6; i++) {
        macStr[j++] = GetHighNib(MyMAC.v[i]);
        macStr[j++] = GetLowNib(MyMAC.v[i]);
    }
    macStr[12] = 0;
    //println_I("MAC address is =");
    print_I(macStr);

    Pic32_Bowler_HAL_Init();
    usb_CDC_Serial_Init(dev, macStr, 0x04D8, 0x3742);
    InitLEDS();
    SetColor(0, 0, 1);

    mInitSwitch();

    //AVR Reset pin
    InitAVR_RST();
    HoldAVRReset();
    //AVR must be running before pin states can be synced in the pin initialization
    ReleaseAVRReset();
    //Starts co-proc uart
    initCoProcCom();
    
    InitPinFunction();
    //Must initialize IO before hardware
    LoadDefaultValues();
    //println_W("Pin States");
    SyncModes();
    //println_I("Modes synced, initializing channels");
    initAdvancedAsync();

    //println_I("Adding IO Namespace");
    addNamespaceToList( get_bcsIoNamespace());
    //println_I("Adding IO.Setmode Namespace");
    addNamespaceToList(get_bcsIoSetmodeNamespace());
    //println_I("Adding DyIO Namespace");
    addNamespaceToList(get_neuronRoboticsDyIONamespace());
    //println_I("Adding PID Namespace");
    addNamespaceToList( getBcsPidNamespace());
    //println_I("Adding DyIO PID Namespace");
    addNamespaceToList( get_bcsPidDypidNamespace());
    //println_I("Adding Safe Namespace");
    addNamespaceToList((NAMESPACE_LIST *) get_bcsSafeNamespace());


    Init_FLAG_BUSY_ASYNC();
    //InitCTS_RTS_HO();

    //ConfigUARTOpenCollector();
    ConfigUARTRXTristate();

    //Starts Timer 3
    InitCounterPins();
    InitADC();



    //SetFwRev(rev);



    GetName(Name);
    if(Name[0]==0xff){
            for(i=0;i<17;i++){
                    Name[i]=defaultName[i] ;
            }
            SetName(Name);
            GetName(Name);
    }

    if (!GetLockCode(LockCode)){
            for(i=0;i<4;i++){
                LockCode[i] = defaultlock[i];
            }
            SetLockCode(LockCode);
    }

    EndCritical();

	initBluetooth();
	if(!hasBluetooth()){
		Pic32UARTSetBaud( 115200 );
	}

    boolean defaultmac=true;
    for (i = 0; (i < 6) && defaultmac; i++) {
    	if(MyMAC.v[i] != MY_MAC_ADDRESS[i]){
    		defaultmac = false;
    	}
    }
    if(defaultmac){
    	srand((unsigned) GetRawVoltage());// random seed from the air

    	MyMAC.v[3] = MINOR_REV;
    	MyMAC.v[4] = FIRMWARE_VERSION;
    	MyMAC.v[5] = rand() % 255;
    	FlashSetMac(MyMAC.v);
		U1CON = 0x0000;
		DelayMs(100);
    	Reset();
    }

}
Exemple #9
0
//*****************************************************************************
//
//! Main 
//!
//! \param None
//!
//! \return None
//
//*****************************************************************************
void 
main()
{
    unsigned int uiConfig,uiSeed=0x0000a5a5,uiDataLength,*puiData,uiResult;
    
    //
    // Initialize Board configurations
    //
    BoardInit();
    
    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    //
    // Enable CRC Module
    //
    MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK);
#ifdef USER_INPUT
    while(FOREVER)
    {
        //
        // Read values either from User or from Vector based on macro USER_INPUT
        // defined or not
        //

        //
        // Read the values from the user over uart and Populate the variables
        //
        puiData=ReadFromUser(&uiConfig,&uiDataLength,&uiResult);
        if(puiData == NULL)
        {
            UART_PRINT("\n\rInvalid Input. Please try again. \n\r");
            continue;
        }
#else
        //
        // Load Default values
        //
        UART_PRINT("Running CRC-16-IBM 0x8005 Vectors\n");
        puiData=LoadDefaultValues(CRC_CFG_INIT_SEED | CRC_CFG_TYPE_P8005 |
                                   CRC_CFG_SIZE_32BIT,
                                   &uiConfig,&uiDataLength,&uiSeed,&uiResult);
#endif

        //
        // Carry out Encryption
        //
        UART_PRINT("\n\r CRC Generation in progress....");
        RunCRC(uiConfig,uiDataLength,uiSeed,puiData,&uiResult);
        UART_PRINT("\n\r CRC Result is generated\n\r");
        
        //
        // Display/Verify Result
        //

#ifdef USER_INPUT
        //
        // Display Plain Text
        //
        UART_PRINT("\n\r The CRC Result in hex is: 0x%02x \n\r",uiResult);
    }
#else
    //
    // Comapre Cipher Text and Plain Text with the expected values from 
    // predefined vector
    //
    UART_PRINT("\n\r The Generated CRC Result in hex is: 0x%02x \n\r",uiResult);
    UART_PRINT("\n\r The Expected CRC in hex is: 0x%02x \n\r",
                                            g_psCRC8005TestVectors.ui32Result);
    if(uiResult==g_psCRC8005TestVectors.ui32Result)
    {
      UART_PRINT("\n\r\n\r CRC result is verified successfully");
    }
    else
    {
      UART_PRINT("\n\r\n\r Error in CRC generation");
    }

    while(FOREVER);

#endif

}