Modbus
シリアル通信プロトコルの一つ
https://ja.wikipedia.org/wiki/Modbus
いくつか種類がある
シリアルポート
Modbus RTU: バイナリ表現
Modbus ASCII: 文字列表現
TCP/IP
Modbus TCP
この層がADU (Aplication Data Unit)に相当する?
https://www.ni.com/ja/shop/labview/introduction-to-modbus-using-labview.html
PDU
Protocol Data Unitの略
monitor
https://github.com/ClassicDIY/ModbusTool
$ winget install ClassicDIY.ModbusTool
https://www.fa.hdl.co.jp/jp/html/app/Modbus_Tool/index.html
日本語
https://www.modbus.org/specs.php
https://www.mgco.jp/mssjapanese/PDF/NM/kaisetsu/nmmodbus.pdf
https://lifeisfruits.com/2020/07/12/modbus_rtu_arduino/
例
Tx 01 03 00 00 00 01 84 0A
01: Address field
slave IDを表す
03:Function field
03はRead Holding Registersを表す
holding registersから指定した数の値を読み取る
holding registersは40001番から始まるので、そこを基準とした番号を渡す
例:40201番を読み取るときは200を指定する
開始アドレス、読み取るレジスタの数の順に並べる
00 00 00 01: Data field
Function codeに準拠したデータ形式
可変長
03では00 00 00 01は
0+40001=40001から
1個データを読み取る
ことを表している
84 0A: Check sum
Modbus ASCIIはLRCを使う
Modbus RTUはCRC-16 algorithmを使う
Rx 01 03 02 00 00 B8 44
typescript
npm:modbus-serial
https://github.com/Cloud-Automation/node-modbus
https://github.com/adrianscheit/web-modbus
Web serial API使用
https://github.com/node-modbus/stream
callback base
https://github.com/LukeL99/simple-modbus/
Modbus TCP実装
副作用と密結合していて、ロジックだけ取り出せない
https://github.com/takker99/modbus-web-monitor
https://github.com/DJWoodZ/Arduino-Modbus-Controller/blob/main/src/plugins/api.js
logicが参考になる
@takker/modbus
#2025-09-02 21:14:21
#2025-08-29 11:14:04
#2025-08-28 13:03:59