# SetRemoteCommandErrorCode

### void SetRemoteCommandErrorCode(int lMsgId, string strCommand, short nParamIndex, short nErrorCode)

호스트로부터 수신한 원격 명령(`S2F41`)의 파라미터 리스트 중, 특정 인덱스의 파라미터에 문제가 있을 때 응답 메시지(`S2F42`)에 포함될 \*\*CPACK(에러 코드)\*\*를 설정합니다.

Parameters

<table data-header-hidden><thead><tr><th width="161" valign="top"></th><th width="75" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">lMsgId</td><td valign="top">int</td><td valign="top">수신한 Remote Command의 Message ID</td></tr><tr><td valign="top">strCommand</td><td valign="top">string</td><td valign="top">수신한 Remote Command의 RCMD</td></tr><tr><td valign="top">nParamIndex</td><td valign="top">short</td><td valign="top">수신한 Remote Command에서 문제가 발생한 Parameter의 Index</td></tr><tr><td valign="top">nErrorCode</td><td valign="top">short</td><td valign="top"><p>문제의 종류(CPACK)</p><p>1 = Parameter Name (CPNAME) does not exist</p><p>2 = Illegal Value specified for CPVAL</p><p>3 = Illegal Format specified for CPVAL</p><p>>3 = Other equipment-specific error</p><p>4-63 Reserved</p></td></tr></tbody></table>

```csharp
public void OnRemoteCommand(int lMsgId)
{
    string strCommand = "", strCPName = "", strCPValue = "";
    int nParamCount = 0;
    int nFormat = 0;

    short nHCACK = 0;

    //---------- 받아서 처리하는 변수 선언 ----------------
    string strLOTID = string.Empty, strPPID = string.Empty;

    nParamCount = m_gem.GetRemoteCommand(lMsgId, ref strCommand);

    for (short i = 0; i < (short)nParamCount; i++)
    {
        int nCntOFParam = m_gem.GetRemoteCommandParam(lMsgId, i, ref strCPName, ref strCPValue, ref nFormat);

        strCPName.ToUpper();
        if (strCPName == CPNAME.LOTID)
        {
            strLOTID = strCPValue;
        }
        else if (strCPName == CPNAME.PPID)
        {
            strPPID = strCPValue;
        }
        else //해당되는 CPNAME이 존재하지 않는 경우. NACK
        {
            nHCACK = 3;
            m_gem.SetRemoteCommandErrorCode(lMsgId, strCommand, i, 3);

        }

        AddLog(string.Format("CPNAME = {0}", strCPName));
        AddLog(string.Format("CPVALUE[{0},{1}] = {2}", nCntOFParam, nFormat, strCPValue));
    }

    



    if (nHCACK != 0)
    {
        // 허용되지 않는 CPNAME이 존재함.
        m_gem.ReplyRemoteCommand(lMsgId, nHCACK);
        return;
    }
    else
    {
        // 
        if (strCommand == RCMD.START)
        {
            //들어온 LOTID나 CSTID,.. 등등을 비교하여 문제가 없으면 해당해서 보냄.
            m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.
            m_gem.SetVIDValue(SVID.LOT_ID, strLOTID);
            m_gem.SendEventReport(CEID.LOT_START);
        }
        else if (strCommand == RCMD.PPSELECT)
        {
            if (strPPID != "")
            {
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.

                m_gem.SetVIDValue(SVID.PPID, strPPID);
                m_gem.SendEventReport(CEID.PP_SELECTED_LOADED);
            }
            else
            {
                nHCACK = 3;//해당되는 레시피 이름이 없는 경우 작업진행 불가.
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.

            }
        }
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nviasoft.gitbook.io/nviasoft-docs/api-reference/undefined-6/setremotecommanderrorcode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
