# SetMsgHead

### int SetMsgHead(int lMsgId, byte\[] pnHeader)

생성된 메시지 객체(`lMsgId`)에 SECS-II 표준의 10바이트 메시지 헤더 정보를 설정합니다. 이 헤더에는 Stream, Function, Device ID, Transaction ID 등 통신에 필요한 모든 주소 정보가 포함됩니다.

Parameters

| **Name** | **Type** | **Description**                             |
| -------- | -------- | ------------------------------------------- |
| lMsgId   | int      | 헤더를 설정할 대상 메시지 ID                           |
| pnHeader | byte\[]  | 10바이트 길이의 헤더 데이터 배열 (Stream, Function 등 포함) |

```csharp
void BuildS1F1Message()
{
    int lMsgId = m_gem.CreateEmptyMsg();
    if (lMsgId > 0)
    {
        // 10바이트 헤더 구성 (예: S1F1)
        // [0][1]: Device ID, [2]: Stream(1) | Wait Bit, [3]: Function(1), ...
        byte[] header = new byte[10] { 0x00, 0x00, 0x81, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
        
        int result = m_gem.SetMsgHead(lMsgId, header);
        
        if (result >= 0)
        {
            // 헤더 설정 성공, 이제 Body를 구성하거나 전송
            m_gem.SendMsg(lMsgId);
        }
    }
}
```


---

# 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/setmsghead.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.
