> For the complete documentation index, see [llms.txt](https://mwm5.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwm5.twelite.info/0.8/references/parser/twefmt/twepacket/newtwepacket.md).

# newTwePacket()

パケットデータのバイト列を入力として、パケット種別の判定と、種別に応じた[`spTwePacket`](/0.8/references/parser/twefmt/twepacket.md)オブジェクトを生成します。

```cpp
spTwePacket newTwePacket(
		uint8_t* p,
		uint8_t u8len,
		E_PKT eType = E_PKT::PKT_ERROR)

spTwePacket newTwePacket(
		TWEUTILS::SmplBuf_Byte& sbuff,
		E_PKT eType = E_PKT::PKT_ERROR)
```

事前に[`identify_packet_type()`](/0.8/references/parser/twefmt/twepacket/idenify_packet_type.md)を用いてパケットの種別[`E_PKT`](/0.8/references/parser/twefmt/twepacket/e_pkt.md)が特定できている場合は`eType`を与えます。

戻り値は[`spTwePacket`](/0.8/references/parser/twefmt/twepacket.md)です。
