FieldTalk Modbus Slave C++ Library
Library version 2.9.1
|
Let's assume we want to implement a Modbus slave device with slave address 1.
The registers for reading are in the reference range 4:00100 to 4:00119 and the registers for writing are in the range 4:00200 to 4:00219. The discretes for reading are in the reference range 0:00010 to 0:00019 and the discretes for writing are in the range 0:00020 to 0:00029.
1. Include the package header files
2. Device data profile definition
Define the data sets which reflects the slave's data profile by type and size:
3. Declare a Data Provider
4. Declare and instantiate a server object and associate it with the Data Provider
5. Start-up the server
6. Execute cyclically the server loop
7. Shutdown the server if not needed any more
Let's assume we want to implement a Modbus slave device with slave address 1.
The registers for reading are in the reference range 4:00100 to 4:00119 and the registers for writing are in the range 4:00200 to 4:00219. The discretes for reading are in the reference range 0:00010 to 0:00019 and the discretes for writing are in the range 0:00020 to 0:00029.
1. Include the package header files
2. Device data profile definition
Define the data sets which reflects the slave's data profile by type and size:
3. Declare a Data Provider
4. Declare and instantiate a server object and associate it with the Data Provider and the slave address.
5. Change the default port from 502 to semething else if server shall not run as root. This step is not necessary when the server can run with root privilege.
6. Start-up the server
7. Execute cyclically the server loop
8. Shutdown the server if not needed any more