# CreateEmptyMsg

### int CreateEmptyMsg()

라이브러리 내부에서 관리되는 빈 메시지 객체를 생성하고, 해당 메시지를 가리키는 고유 ID(MsgID)를 반환합니다. 이 ID를 통해 이후 단계에서 메시지의 Header(Stream, Function)를 설정하거나 Body(Item List)를 채워 넣게 됩니다.

```csharp
void SendCustomMessage()
{
    // 1. 빈 메시지 객체 생성
    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);
        
        int result = m_gem.SetMsgBody(lMsgId, recipeData, dataSize);
        // 3. 메시지 전송
        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-4/createemptymsg.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.
