コード例 #1
0
ファイル: cipidentity.c プロジェクト: hicder/toc-opener
static EIP_STATUS Reset(S_CIP_Instance *pa_pstInstance, /* pointer to instance*/
    S_CIP_MR_Request *pa_stMRRequest, /* pointer to message router request*/
    S_CIP_MR_Response *pa_stMRResponse) /* pointer to message router response*/
  {
	EIP_STATUS nRetVal;
    (void)pa_pstInstance;

    nRetVal = EIP_OK_SEND;

    pa_stMRResponse->ReplyService = (0x80 | pa_stMRRequest->Service);
    pa_stMRResponse->SizeofAdditionalStatus = 0;
    pa_stMRResponse->GeneralStatus = CIP_ERROR_SUCCESS;

    if (pa_stMRRequest->DataLength == 1)
      {
        switch (pa_stMRRequest->Data[0])
          {
        case 0: /*emulate device reset*/
          if (EIP_ERROR == IApp_ResetDevice())
            {
              pa_stMRResponse->GeneralStatus = CIP_ERROR_INVALID_PARAMETER;
            }
          break;

        case 1: /*reset to device settings*/
          if (EIP_ERROR == IApp_ResetDeviceToInitialConfiguration())
            {
              pa_stMRResponse->GeneralStatus = CIP_ERROR_INVALID_PARAMETER;
            }
          break;

        default:
          pa_stMRResponse->GeneralStatus = CIP_ERROR_INVALID_PARAMETER;
          break;
          }
      }
    else
      {
        /*The same behavior as if the data value given would be 0
          emulate device reset*/
        if (EIP_ERROR == IApp_ResetDevice())
          {
            pa_stMRResponse->GeneralStatus = CIP_ERROR_INVALID_PARAMETER;
          }
        else
          {
         // nRetVal = EIP_OK;
          }
      }
    pa_stMRResponse->DataLength = 0;
    return nRetVal;
  }
コード例 #2
0
ファイル: sampleapplication.c プロジェクト: longyn/OpENer
EIP_STATUS
IApp_ResetDeviceToInitialConfiguration(void)
{
  /*rest the parameters */

  /*than perform device reset*/
  IApp_ResetDevice();
  return EIP_OK;
}