/**
 * decodeAndRunPending
 * @param cmd - command that will be executed
 * RETURN: none
 * INFO: Once a command is to be processed it is passed into this function and it is executed.
 *       A switch statement is used in a similar function to the old version of the command parser
 *       to call the command specified by the opcode.
 */
void decodeAndRunPending(seq_command_t cmd){
    int16_t reformatResult;
    BYTE reformatMode = 1;
    journal_t journalTemp;
    
    switch(cmd.opcode){
        case OP_START_SEQUENCE: //start sequence
            dprintf("Start sequence\r\n");
            break;
        case OP_LOAD_RADIO_CONFIGURATION: //load radio config
            //store away a copy of the journal structure
            Journal_GetStruct(&journalTemp);
            journalTemp.radioConfigs = Global->csSequence.configs;
            Journal_SetStruct(&journalTemp);

            //Send a pointer to the radio configuration structure to Radio Code.
            radioConfig(&Global->csSequence.configs);
            dprintf("Radio Configuration\r\n");
            break;
        case OP_RELOAD_RADIO_CONFIGURATION: //reload default radio configs
            //Send null to radio, indicating to load defualt values
            dprintf("Reload Radio Configuration\r\n");
            Journal_GetStruct(&journalTemp);
            radioConfig(&journalTemp.radioConfigs);
            break;
        case OP_SET_SWITCH://set swith
            setPCASwitch(cmd.params.set_switch.pca_id,cmd.params.set_switch.config);
            dprintf("PCA %u configured as %u\r\n",cmd.params.set_switch.pca_id,cmd.params.set_switch.config);
            //cmd.params.set_switch.id;
            break;
        case OP_PROCESSOR_MODE: //processor mode
            setProcMode(cmd.params.set_proc_mode.mode);
            dprintf("Processor mode has been set.\r\n");
            break;
        case OP_CHECK_SD_CARD: //check SD
            checkSDCard();
            dprintf("SD card check complete.\r\n");
            break;
        case OP_REFORMAT_SD: //reformat SD
            reformatResult = FSformat(reformatMode,0,NULL);
            if(!reformatResult){
                dprintf("SD card reformatted successfully\r\n");
                if (!Storage_Init()) {
                    dprintf("Unable to init SD card. Error: %d\n", FSerror());
                }
            }
            else{
                dprintf("SD card reformat had an error: %d\n", FSerror());
            }
            break;
        case OP_END_SEQUENCE://end sequence
            dprintf("End Sequence\r\n");
            beaconMsgUpdateSingle(SOFTWARE_STATE,'C');
            break;
        default: //uh oh
            dprintf("UNKNOWN PENDING COMMAND IN SEQUENCE\r\n");
            break;

    }
}
Example #2
0
uint8_t fsmanFormat(void){

    __debug("Formatting Drive");
    uint8_t res =  FSformat (0, 0, "OPENXC");
    __debug("Formatting Complete %d",res);
    if(res == CE_GOOD)
        return 1;
    
    return 0;
}
Example #3
0
int FileFormat(char mode, long int serialNumber, char *volumeID)
{
    #if defined STACK_USE_MPFS2
        int status;
        status = MPFSFormat();
        if(status == MPFS_INVALID_HANDLE)
            return -1;
        else
            return 0;
    #elif defined STACK_USE_MDD 
        return FSformat(mode, serialNumber, volumeID);
    #endif
}