Пример #1
0
static void DisplayIPValue(IP_ADDR *IPVal, BOOL bToLCD)
{
    char IPDigit[8];

    /*
     * Rewrite the second line.
     */
    itoa(IPVal->v[0], IPDigit);
    {
        serPutString((BYTE*)IPDigit);
        serPutByte('.');
    }

    itoa(IPVal->v[1], IPDigit);
    {
        serPutString((BYTE*)IPDigit);
        serPutByte('.');
    }

    itoa(IPVal->v[2], IPDigit);
    {
        serPutString((BYTE*)IPDigit);
        serPutByte('.');
    }

    itoa(IPVal->v[3], IPDigit);
	{
        serPutString((BYTE*)IPDigit);
	}
}
Пример #2
0
void ExecuteMenuChoice(MENU_CMD choice)
{
    char response[MAX_USER_RESPONSE_LEN];
    IP_ADDR tempIPValue;
    IP_ADDR *destIPValue;

    serPutByte('\r');
    serPutByte('\n');
    serPutRomString(menuCommandPrompt[choice-'0'-1]);

    switch(choice)
    {
    case MENU_CMD_SERIAL_NUMBER:
        itoa(AppConfig.SerialNumber.Val, response);
        serPutString((BYTE*)response);
        serPutByte(')');
        serPutByte(':');
        serPutByte(' ');

        if ( USARTGetString(response, sizeof(response)) )
        {
            AppConfig.SerialNumber.Val = atoi(response);

            AppConfig.MyMACAddr.v[4] = AppConfig.SerialNumber.v[1];
            AppConfig.MyMACAddr.v[5] = AppConfig.SerialNumber.v[0];
        }
        else
            goto HandleInvalidInput;

        break;

    case MENU_CMD_IP_ADDRESS:
        destIPValue = &AppConfig.MyIPAddr;
        goto ReadIPConfig;

    case MENU_CMD_GATEWAY_ADDRESS:
        destIPValue = &AppConfig.MyGateway;
        goto ReadIPConfig;

    case MENU_CMD_SUBNET_MASK:
        destIPValue = &AppConfig.MyMask;

    ReadIPConfig:
        DisplayIPValue(destIPValue, FALSE);
        serPutByte(')');
        serPutByte(':');
        serPutByte(' ');

        USARTGetString(response, sizeof(response));

        if ( !StringToIPAddress(response, &tempIPValue) )
        {
HandleInvalidInput:
            serPutRomString(InvalidInputMsg);
            while( !serIsGetReady() );
            serGetByte();
        }
        else
        {
            destIPValue->Val = tempIPValue.Val;
        }
        break;


    case MENU_CMD_ENABLE_AUTO_CONFIG:
        AppConfig.Flags.bIsDHCPEnabled = TRUE;
        break;

    case MENU_CMD_DISABLE_AUTO_CONFIG:
        AppConfig.Flags.bIsDHCPEnabled = FALSE;
        break;

    case MENU_CMD_DOWNLOAD_MPFS:
#if defined(MPFS_USE_EEPROM)
        DownloadMPFS();
#endif
        break;

    case MENU_CMD_QUIT:
#if defined(MPFS_USE_EEPROM)
        appcfgSave();
#endif
        break;
    }
}
Пример #3
0
void ExecuteMenuChoice(MENU_CMD choice)
{
    char response[MAX_USER_RESPONSE_LEN];
    IP_ADDR tempIPValue;
    IP_ADDR *destIPValue;
    WORD_VAL w;
    BYTE offset;

    serPutByte('\r');
    serPutByte('\n');
    serPutRomString(menuCommandPrompt[choice-'0'-1]);

    switch(choice)
    {
    case MENU_CMD_SERIAL_NUMBER:
        w.byte.LSB = appcfgGetc(APPCFG_SERIAL_NUMBER0);
        w.byte.MSB = appcfgGetc(APPCFG_SERIAL_NUMBER1);
        itoa(w.Val, response);
        serPutString((BYTE*)response);
        serPutByte(')');
        serPutByte(':');
        serPutByte(' ');

        if ( USARTGetString(response, sizeof(response)) )
        {
            w.Val = atoi(response);
            appcfgPutc(APPCFG_SERIAL_NUMBER0, w.byte.LSB);
            appcfgPutc(APPCFG_SERIAL_NUMBER1, w.byte.MSB);

            AppConfig.MyMACAddr.v[4] = w.byte.MSB;
            AppConfig.MyMACAddr.v[5] = w.byte.LSB;
        }
        else
            goto HandleInvalidInput;

        break;

    case MENU_CMD_IP_ADDRESS:
        destIPValue = &AppConfig.MyIPAddr;
        offset = APPCFG_IP0;
        goto ReadIPConfig;

    case MENU_CMD_GATEWAY_ADDRESS:
        destIPValue = &AppConfig.MyGateway;
        offset = APPCFG_GATEWAY0;
        goto ReadIPConfig;

    case MENU_CMD_SUBNET_MASK:
        destIPValue = &AppConfig.MyMask;
        offset = APPCFG_MASK0;

    ReadIPConfig:
        scfDisplayIPValue(destIPValue);
        serPutByte(')');
        serPutByte(':');
        serPutByte(' ');

        USARTGetString(response, sizeof(response));

        if ( !StringToIPAddress(response, &tempIPValue) )
        {
HandleInvalidInput:
            serPutRomString(InvalidInputMsg);
            while( !serIsGetReady() );
            serGetByte();
        }
        else
        {
            destIPValue->Val = tempIPValue.Val;
            
            //Update new configuration data just entered
            appcfgPutc(offset++, tempIPValue.v[0]);
            appcfgPutc(offset++, tempIPValue.v[1]);
            appcfgPutc(offset++, tempIPValue.v[2]);
            appcfgPutc(offset++, tempIPValue.v[3]);
        }
        break;


    case MENU_CMD_ENABLE_AUTO_CONFIG:
        //Set DHCP flag
        appcfgPutc(APPCFG_NETFLAGS, appcfgGetc(APPCFG_NETFLAGS) | APPCFG_NETFLAGS_DHCP);
        break;

    case MENU_CMD_DISABLE_AUTO_CONFIG:
        //Clear DHCP flag
        appcfgPutc(APPCFG_NETFLAGS, appcfgGetc(APPCFG_NETFLAGS) & ~APPCFG_NETFLAGS_DHCP);
        break;

    case MENU_CMD_DOWNLOAD_FSYS_IMAGE:
        DownloadFsysImage();
        break;

    case MENU_CMD_QUIT:
        break;
    }
}