예제 #1
0
파일: cmd.c 프로젝트: eschaler/roach
void cmdPushFunc(MacPacket rx_packet) {
    Payload rx_payload;
    unsigned char command;

    rx_payload = macGetPayload(rx_packet);
    if(rx_payload != NULL) {
        command = payGetType(rx_payload);

        if(command < MAX_CMD_FUNC && cmd_func[command] != NULL) {
            rx_payload->test = cmd_func[command];
            carrayAddTail(fun_queue, rx_packet);
        } else {
            cmdError();   // halt on error - could also just ignore....
        }
    }
}
void SessionServer::rloop()
{
	if(!validHeader())
		return;
	char cmd[_CMD_SIZE + 1];
	cmd[_CMD_SIZE] = '\0';
	if(!readSBuf(cmd, _CMD_SIZE))
		return;
	if(strcmp(cmd, "cdr") == 0)
		createFolder();
	else if(strcmp(cmd, "cfl") == 0)
		createFile();
	else if(strcmp(cmd, "rdr") == 0)
		readFolder();
	else if(strcmp(cmd, "cmd") == 0)
		changeModel();
	else if(strcmp(cmd, "ofl") == 0)
		openFile();
	else if(strcmp(cmd, "rfl") == 0)
		readFile();
	else if(strcmp(cmd, "wfl") == 0)
		writeFile();
	else if(strcmp(cmd, "skf") == 0)
		seekFile();
	else if(strcmp(cmd, "tlf") == 0)
		tellFile();
	else if(strcmp(cmd, "csf") == 0)
		closeFile();
	else if(strcmp(cmd, "del") == 0)
		deleteItem();
	else if(strcmp(cmd, "gsf") == 0)
		getItemSafeInfo();
	// else if(strcmp(cmd, "fdk") == 0)
	// 	formatDisk(); 
	else if(strcmp(cmd, "lgt") == 0)
		logout();
	else if(strcmp(cmd, "aur") == 0)
		addUsr();
	else if(strcmp(cmd, "cpd") == 0)
		changePsd();
	else
		cmdError();
}
예제 #3
0
  bool SdCardSdioFeature::powerOn() {

    SD_Error errorstatus=SD_OK;
    uint32_t response=0,count=0,validvoltage=0;
    uint32_t SDType=SD_STD_CAPACITY;
    SDIO_InitTypeDef sdioInit;
    SDIO_CmdInitTypeDef cmdInit;

    /*!< Power ON Sequence -----------------------------------------------------*/

    sdioInit.SDIO_ClockDiv=_initDivider;
    sdioInit.SDIO_ClockEdge=SDIO_ClockEdge_Rising;
    sdioInit.SDIO_ClockBypass=SDIO_ClockBypass_Disable;
    sdioInit.SDIO_ClockPowerSave=SDIO_ClockPowerSave_Disable;
    sdioInit.SDIO_BusWide=SDIO_BusWide_1b;
    sdioInit.SDIO_HardwareFlowControl=SDIO_HardwareFlowControl_Disable;
    SDIO_Init(&sdioInit);

    /*!< Set Power State to ON */
    SDIO_SetPowerState(SDIO_PowerState_ON);

    /*!< Enable SDIO Clock */
    SDIO_ClockCmd(ENABLE);

    /*!< CMD0: GO_IDLE_STATE ---------------------------------------------------*/
    /*!< No CMD response required */
    cmdInit.SDIO_Argument=0x0;
    cmdInit.SDIO_CmdIndex=SD_CMD_GO_IDLE_STATE;
    cmdInit.SDIO_Response=SDIO_Response_No;
    cmdInit.SDIO_Wait=SDIO_Wait_No;
    cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
    SDIO_SendCommand(&cmdInit);

    errorstatus=cmdError();

    if(errorstatus != SD_OK)
      return errorProvider.set(ErrorProvider::ERROR_PROVIDER_SD_SDIO,E_SDIO_ERROR,errorstatus);

    /*!< CMD8: SEND_IF_COND ----------------------------------------------------*/
    /*!< Send CMD8 to verify SD card interface operating condition */
    /*!< Argument: - [31:12]: Reserved (shall be set to '0')
     - [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
     - [7:0]: Check Pattern (recommended 0xAA) */
    /*!< CMD Response: R7 */

    cmdInit.SDIO_Argument=SD_CHECK_PATTERN;
    cmdInit.SDIO_CmdIndex=SDIO_SEND_IF_COND;
    cmdInit.SDIO_Response=SDIO_Response_Short;
    cmdInit.SDIO_Wait=SDIO_Wait_No;
    cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
    SDIO_SendCommand(&cmdInit);

    errorstatus=cmdResp7Error();

    if(errorstatus == SD_OK) {
      _cardType=SDIO_STD_CAPACITY_SD_CARD_V2_0; /*!< SD Card 2.0 */
      SDType=SD_HIGH_CAPACITY;
    } else {
      /*!< CMD55 */
      cmdInit.SDIO_Argument=0x00;
      cmdInit.SDIO_CmdIndex=SD_CMD_APP_CMD;
      cmdInit.SDIO_Response=SDIO_Response_Short;
      cmdInit.SDIO_Wait=SDIO_Wait_No;
      cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
      SDIO_SendCommand(&cmdInit);
      errorstatus=cmdResp1Error(SD_CMD_APP_CMD);
    }
    /*!< CMD55 */
    cmdInit.SDIO_Argument=0x00;
    cmdInit.SDIO_CmdIndex=SD_CMD_APP_CMD;
    cmdInit.SDIO_Response=SDIO_Response_Short;
    cmdInit.SDIO_Wait=SDIO_Wait_No;
    cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
    SDIO_SendCommand(&cmdInit);
    errorstatus=cmdResp1Error(SD_CMD_APP_CMD);

    /*!< If errorstatus is Command TimeOut, it is a MMC card */
    /*!< If errorstatus is SD_OK it is a SD card: SD card 2.0 (voltage range mismatch)
     or SD card 1.x */
    if(errorstatus == SD_OK) {
      /*!< SD CARD */
      /*!< Send ACMD41 SD_APP_OP_COND with Argument 0x80100000 */
      while((!validvoltage) && (count < SD_MAX_VOLT_TRIAL)) {

        /*!< SEND CMD55 APP_CMD with RCA as 0 */
        cmdInit.SDIO_Argument=0x00;
        cmdInit.SDIO_CmdIndex=SD_CMD_APP_CMD;
        cmdInit.SDIO_Response=SDIO_Response_Short;
        cmdInit.SDIO_Wait=SDIO_Wait_No;
        cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
        SDIO_SendCommand(&cmdInit);

        errorstatus=cmdResp1Error(SD_CMD_APP_CMD);

        if(errorstatus != SD_OK)
          return errorstatus;

        cmdInit.SDIO_Argument=SD_VOLTAGE_WINDOW_SD | SDType;
        cmdInit.SDIO_CmdIndex=SD_CMD_SD_APP_OP_COND;
        cmdInit.SDIO_Response=SDIO_Response_Short;
        cmdInit.SDIO_Wait=SDIO_Wait_No;
        cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
        SDIO_SendCommand(&cmdInit);

        errorstatus=cmdResp3Error();
        if(errorstatus != SD_OK)
          return errorstatus;

        response=SDIO_GetResponse(SDIO_RESP1);
        validvoltage=(((response >> 31) == 1) ? 1 : 0);
        count++;
      }
      if(count >= SD_MAX_VOLT_TRIAL) {
        errorstatus=SD_INVALID_VOLTRANGE;
        return errorstatus;
      }

      if(response&=SD_HIGH_CAPACITY)
        _cardType=SDIO_HIGH_CAPACITY_SD_CARD;

    }/*!< else MMC Card */

    if(errorstatus != SD_OK)
      return errorProvider.set(ErrorProvider::ERROR_PROVIDER_SD_SDIO,E_SDIO_ERROR,errorstatus);

    return true;
  }