TG9541 / stm8ef-modbus

A lightweight framework for MODBUS RTU nodes in STM8 eForth that can do more than just I/O
https://github.com/TG9541/stm8ef/wiki/Board-C0135
MIT License
32 stars 12 forks source link

Improve FC>XT for some FC codes > FC16 #47

Closed TG9541 closed 2 years ago

TG9541 commented 2 years ago

Improve the implementation of FC>XT so that FC23 ("Read/Write Multiple Registers") and FC24 ("Read FIFO Queue") can be mapped into the 16 word FC-XT table. This shall be done with a simple hash that subtracts 11 from any FC number > 16.

The result is the following mapping which allows implementing all FCs customary in MODBUS-RTU (but not all at once):

FC Function FC-XT Table Index
1 Read Coils 0
2 Read Discrete Inputs 1
3 Read Multiple Holding Registers 2
4 Read Input Registers 3
5 Write Single Coil 4
6 Write Single Holding Register 5
7 Read Exception Status 6
8 Diagnostic 7
(9) invalid 8
(10) invalid 9
11 Get Com Event Counter 10
12 Get Com Event Log 11
(13) invalid 12
(14) invalid 13
15 Write Multiple Coils 14
16 Write Multiple Holding Registers 15
17 Report Server ID 6
(18) invalid 7
(19) invalid 8
20 Read File Record 9
21 Write File Record 10
22 Mask Write Register 11
23 Read/Write Multiple Registers 12
24 Read FIFO Queue 13

If needed FC43 (both "Read Device Identification" and "Encapsulated Interface Transport") can be implemented with the default handler