# E17 Endianness

### 定義

設定位元組順序，可選大端序(最高有效位元組)、小端序(最低有效位元組)、暫存器交換或位元組和暫存器皆交換，預設Big Endian大端序。

本參數用來調整 RX (流量計回傳資料) 時每個多 byte 資料的內部 byte 傳輸順序。**modbus ID、指令、CRC及單 byte 資料不受影響。** 例如要傳回傳流量及流速資料假設流量的數據是1000，回傳時，仍會先傳流量再傳流速，但是用來表達1000的這4個 byte 的傳輸順序不同，1000表示為16進制是 00007A44，以下是兩個不同格式時的順序。(下圖每個菱形圖示是一個 byte。)

<div align="left"><figure><img src="https://docs.lorric.com/qr/~gitbook/image?url=https%3A%2F%2F598628291-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FYbqXsfQyaXKmr6mxssGy%252Fuploads%252F8TXvmhXtzoghnGW9QkSG%252Fendianness.png%3Falt%3Dmedia%26token%3D8a6429b8-4cba-4a83-9797-d4939920d866&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=b61a042d&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

**範例**

以下是使用 04 指令要求流量計傳回瞬時流速(圖示為FS+數字)及累積流量(圖示為TF+數字)的範例：(下圖每個菱形圖示是一個 byte)

<div align="left"><figure><img src="https://docs.lorric.com/qr/~gitbook/image?url=https%3A%2F%2F598628291-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FYbqXsfQyaXKmr6mxssGy%252Fuploads%252FuzspcU5ExoovvCdjSGQ1%252Fendian_example.png%3Falt%3Dmedia%26token%3Decb4d649-01d6-45e7-ba7b-6be3f5a1cd89&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=fe7f93e0&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

第一行是主控端發出的指令。不受本設定影響，詳細請看 modbus 04 指令。

第二行是流量計在 Big Endian 設置下的回覆。從左到右，0x01 到 0x08 及 CRC1到CRC2 不是資料不受本設定影響。瞬時流速(圖示為FS+數字)及累積流量(圖示為TF+數字)回覆順序也不受影響。因為設定為 Big Endian，瞬時流速(圖示為FS3 到 FS0) 的四個 byte 會先從 FS3 開始回覆。累積流量(圖示為TF3 到 TF0) 的四個 byte 會先從 TF3 開始回覆。

第三行是流量計在 Little Endian 設置下的回覆。從左到右，0x01 到 0x08 及 CRC1到CRC2 不是資料不受本設定影響。瞬時流速(圖示為FS+數字)及累積流量(圖示為TF+數字)回覆順序也不受影響。因為設定為 Little Endian，瞬時流速(圖示為FS0 到 FS3) 的四個 byte 會先從 FS0 開始回覆。累積流量(圖示為TF0 到 TF3) 的四個 byte 會先從 TF0 開始回覆。

#### Modbus 不同格式間的轉換器

{% embed url="<https://codepen.io/philo_lorric/pen/BagqoRj>" %}

#### 位元組順序說明

假設一個 32 位元數據由 4 個位元組 (A：最高位元組，D：最低位元組) 組成，並且儲存在兩個 16 位元的暫存器中 ($$\mathbf{Reg1 = A B}$$, $$\mathbf{Reg2 = C D}$$)。

| **類型**            | **傳輸順序 (Hex)**          |
| ----------------- | ----------------------- |
| Big Endian        | $$\mathbf{A~~B~~C\~D}$$ |
| Little Endian     | $$\mathbf{D~~C~~B\~A}$$ |
| Mid Big Endian    | $$\mathbf{C~~D~~A\~B}$$ |
| Mid Little Endian | $$\mathbf{B~~A~~D\~C}$$ |

### 注意事項

1. E17 Endianness 支援使用 RS485 修改。
2. E17 Endianness 的設定必須與接收端（Master）的程式設定完全一致。
3. 細節請見[RS485 與 Modbus RTU 設定](https://docs.lorric.com/fues-echosense-yi-ti-shi-chao-yin-bo-liu-liang-ji-v1.0/communication/rs485-setup)

### 操作流程

<details>

<summary><strong>按鍵名稱及說明</strong>（點擊展開）</summary>

主機共有4個按鍵。LCD 最下方(第 3 行)會顯示目前所有按鍵各自的功能。一般情況下，按鍵定義如下：

* <img src="/files/lDfiuH2Ibq1AeX1QpL2f" alt="" data-size="line"> 藍鍵：最左邊的按鍵，返回上一頁、離開目前操作或存檔

&#x20;方向鍵-灰鍵：

* <img src="/files/MfCyTiq7YBh2TxBAQDYB" alt="" data-size="line"> 左灰鍵 - 用於翻頁、增大數值、選擇不同項目
* <img src="/files/UxXNkrDuXahe3CWQtczE" alt="" data-size="line"> 右灰鍵 - 用於翻頁、減小數值、選擇不同項目
* <img src="/files/VJOWgDbmy0d4napPWBEP" alt="" data-size="line"> 橘鍵：最右邊的按鍵，進入設定、編輯或確認目前選擇

{% hint style="danger" %}
警告：請勿長時間持續按住按鍵，以免造成按鍵損壞。
{% endhint %}

{% hint style="info" %}
註：按鍵定義會根據操作情境調整。為了提升使用便利性，或避免誤觸，在某些畫面中按鍵功能可能會被刻意變更。
{% endhint %}

</details>

```
E17 Endianness 設定流程：
• 主畫面（綠燈）→ 按右下角橘鍵 Setup，進入設定頁（橘燈）
• 方向鍵選 E. Commute 通訊 → 按橘鍵 Enter
• 方向鍵選 E17 Endianness → 按橘鍵 Enter
• 方向鍵選擇 Endianness 選項 → 按橘鍵 Set 確認
• 按左下角藍鍵ESC返回至主畫面（綠燈）
```

<figure><img src="/files/JFQQi6DTgvvVDSLs4dNp" alt="" width="375"><figcaption></figcaption></figure>

### E17 選項 及 RS485對應數值、讀寫指令及格式

| 選項                | 說明         | RS-485 對應數字 |
| ----------------- | ---------- | ----------- |
| Big Endian (預設值)  | 大端序        | 0           |
| Little Endian     | 小端序        | 1           |
| Mid Big Endian    | 暫存器交換      | 2           |
| Mid Little Endian | 位元組和暫存器皆交換 | 3           |

> Modbus 指令格式請參照[讀寫記憶體列表](https://docs.lorric.com/qr/fu-lt-ultrasonic-flowmeter-manual-chinese-v1/communication/modbus-rtu-protocol/du-xie-xing-ji-yi-ti-lie-biao)，本參數資料形式為int16。


---

# 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://docs.lorric.com/qr/fu-lt-ultrasonic-flowmeter-manual-chinese-v1/parameters/e-tong-xun-xiang-guan-she-ding/e17-endianness.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.
