# GetMsgHead

### int GetMsgHead(int lMsgId, byte\[] pnHeadBuff)

지정한 메시지 ID(`lMsgId`)로부터 10바이트의 SECS-II 헤더 정보를 추출하여 사용자가 제공한 바이트 배열(`pnHeadBuff`)에 담아줍니다. 수신된 메시지를 분석할 때 가장 먼저 호출하게 되는 필수 함수입니다.

Parameters

<table data-header-hidden><thead><tr><th width="187"></th><th width="152"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>lMsgId</td><td>int</td><td>헤더를 읽어올 대상 메시지 ID</td></tr><tr><td>pnHeadBuff</td><td>byte[]</td><td>(Output) 읽어온 10바이트 헤더를 저장할 버퍼 배열</td></tr></tbody></table>

```csharp
void AnalyzeReceivedMessage(int lMsgId)
{
    byte[] header = new byte[10];
    int result = m_gem.GetMsgHead(lMsgId, header);

    if (result > 0)
    {
        // SECS 표준에 따른 헤더 분석
        int deviceId = (header[0] << 8) | header[1];
        int stream = header[2] & 0x7F; // W-Bit 제외
        int function = header[3];

        Console.WriteLine($"수신 메시지 정보: S{stream}F{function}, DeviceID: {deviceId}");
    }
}
```


---

# 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/item-parsing/getmsghead.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.
