# 出力書式

## 初期設定

初期モードではインタラクティブモードの`h: set header format`を設定することで書式を自由に設定できます。

初期設定では、書式が以下のように設定されています。

```
;U;%t;%i;0x%A;%q;%s;<*>;%X;\n
```

この設定の意味は以下の通りです。

| 文字      | 内容                                                                                                             |
| ------- | -------------------------------------------------------------------------------------------------------------- |
| %t      | メッセージを出力したときのシステム時間（秒）                                                                                         |
| %i      | <p>メッセージの送り主の8bit論理アドレス<br>  <code>0-100,120</code>: 子機から</p><p>  <code>219</code>: 自身から(起動時や送信完了メッセージの場合)</p> |
| %A      | メッセージの送り主のアドレス(32bitロングアドレス、シリアル番号)                                                                            |
| %q      | 電波強度 (自身からの場合は`000`)                                                                                           |
| %s      | 送信元が設定したメッセージの続き番号                                                                                             |
| <       | チェックサム計算開始位置を設定する（設定しない場合は出力の先頭）                                                                               |
| \*      | 送信文字列                                                                                                          |
| >       | （無視されます）                                                                                                       |
| %X      | 開始位置から直前までのチェックサムの出力                                                                                           |
| \n      | CRLF (0x0d 0x0a) の出力                                                                                           |
| それ以外の文字 | そのまま出力                                                                                                         |

例えば送信側から`HELLO<Enter>`と入力した場合、出力側からは以下のように出力され、それぞれのデータの意味は下表の通りです。

```
;U;00777;120;0x81025A17;120;013;HELLO;79;
;1;2----;3--;4---------;5--;6--;7----;8-;
```

| No. | 意味                                                                 |
| --- | ------------------------------------------------------------------ |
| 1   | 固定 (データの識別子としてご使用ください。)                                            |
| 2   | 受信側が起動してから777s後に受信した。                                              |
| 3   | 送信機の論理アドレスが120(0x78)                                               |
| 4   | 送信機のシリアル番号が1025A17(先頭の8は通常、読み飛ばします。)                               |
| 5   | 電波強度が120                                                           |
| 6   | 送信機が起動してから13回目の送信データ                                               |
| 7   | 送信データ                                                              |
| 8   | HELLO; のチェックサム (0x48 xor 0x45 xor 0x4C xor 0x4C xor 0x4F xor 0x3B) |

出力の設定の詳細については[出力のカスタマイズ](https://twelite.gitbook.io/mw-pug-uart/mode_selection/mode_e/customize_output)をご覧ください。

{% content-ref url="../mode\_selection/mode\_e/customize\_output" %}
[customize\_output](https://twelite.gitbook.io/mw-pug-uart/mode_selection/mode_e/customize_output)
{% endcontent-ref %}

## 出力の変更例

実際に設定を変更してみましょう。

例えば、Excelで取り扱いやすくするためにカンマ(,)でデータを区切り、付加情報を送信機のシリアル番号と電波強度、続き番号のみにすると設定は以下のようになります。

```
--- CONFIG/TWE UART APP V1-04-5/SID=0x82018ca0/LID=0x78 -- ---
...
 h: set header format [%A,%q,%s,*\n]
...
---
 S: save Configuration
 R: reset to Defaults
```

この設定をし、送信側から`HELLO<Enter>`と入力した場合、出力側からは以下のように出力されます。

```
81025A17,120,013,HELLO
```


---

# Agent Instructions: 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://twelite.gitbook.io/mw-pug-uart/usage/change-output-format.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.
