> For the complete documentation index, see [llms.txt](https://twelite.gitbook.io/mw-pug-uart/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://twelite.gitbook.io/mw-pug-uart/mode_selection/mode_e/customize_output.md).

# 出力のカスタマイズ

ヘッダ付き透過モード (E) の出力はインタラクティブモードの`h: set header format`で設定できます。

一番簡単な書式は`*\n`で、送信されたデータそのものを表示し、CRLFの改行コードを付与します。

```
--- CONFIG/TWE UART APP V1-04-5/SID=0x810a479c/LID=0x01 -E ---
...
 h: set header format [*\n] 
 
受信側で上記の設定を行うと、以下のように表示されます。
 [送信側] HELLO<CR><LF> または HELLO<LF>
 [受信側] HELLO<CR><LF>
```

特殊文字を含めることで様々な出力が可能です。

| 文字    | 意味                                            |
| ----- | --------------------------------------------- |
| `*`   | 送信文字列                                         |
| `&hl` | 任意の文字を１６進数で指定 (例：`&20`→0x20空白)                |
| `<`   | チェックサム計算開始位置を設定する（設定しない場合は出力の先頭）              |
| `>`   | チェックサム計算終了位置を指定する(v1.4.6以降。それ以前のバージョンは無視されます） |

`\`(バックスラッシュ, ￥)に続く文字

|      |                      |
| ---- | -------------------- |
| `\n` | CRLF (0x0d 0x0a) の出力 |
| `\t` | TAB の出力              |
| `\*` | `*`の出力               |
| `\%` | `%`の出力               |
| `\<` | `<`の出力               |
| `\>` | `>`の出力               |
| `\&` | `&`の出力               |

`%`に続く文字

|      |                            |
| ---- | -------------------------- |
| `%A` | 送信元アドレス(32bit)の出力（８桁１６進数）  |
| `%a` | 送信元アドレス(32bit)の出力（１０桁１０進数） |
| `%I` | 送信元論理アドレス(8bit)の出力（２桁１６進数） |
| `%i` | 送信元論理アドレス(8bit)の出力（３桁１０進数） |
| `%T` | 現在のシステム時間（秒）の出力（４桁１６進数）    |
| `%t` | 現在のシステム時間（秒）の出力（５桁１０進数）    |
| `%S` | 送信元が設定した続き番号の出力（２桁１６進数）    |
| `%s` | 送信元が設定した続き番号の出力（３桁１０進数）    |
| `%Q` | 受信時の電波強度を出力（２桁１６進数）        |
| `%q` | 受信時の電波強度を出力（３桁１０進数）        |
| `%X` | チェックサムの出力（２桁１６進数）          |
| `%x` | チェックサムの出力（３桁１０進数）          |

### チェックサムの計算

チェックサムは開始位置（<で指定する場合はその場所から、なければ出力の先頭）から`%X`,`%x`の出力直前までをXOR（排他的論理和）にて計算します。

```
 h: set header format [;%I;*;%X]
 上記のように設定した場合、
 
受信側で上記の設定を行うと、以下のように表示されます。
 [送信側] HELLO<CR><LF> または HELLO<LF>
 [受信側] ;000;HELLO;49

送信側のアドレスはでHELLOという文字が届きチェックサムが0x49です。
チェックサムの計算範囲は ;000;HELLO; です。
```

#### 計算プログラム例

```c
#include <stdio.h>

int main() {
  unsigned char x = 0;
  char *p = ";000;HELLO;";

  while(*p) {
    x ^= *p;
    p++;
  }
  printf("%s -> %02x\n", argv[1], x);
}

// ;000;HELLO; -> 49
```


---

# 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, and the optional `goal` query parameter:

```
GET https://twelite.gitbook.io/mw-pug-uart/mode_selection/mode_e/customize_output.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
