WIKI : Sample apps with Modbus protocol over serial port


Hello all,

Just a message to share with you small application who use a FDTI USB serial port and modbus protocole.

This is a good base if you want to implement data access with serial port over modbus protocol.
Only function 3 and 16 are implemented with CRC calculation but it’s easy to add more.

I use le_fdMonitor_Create() to pollin into a handler incomming modbus messages. Apps use a circular buffer to “eject” bad data and read only a good modbus frame. You will find example to read/write data to a C Struct over modbus.

This was tested with MAngoh red and WP76 / R9 and legato 18.05. Driver for FDTI USB serial port is loaded at apps startup. (162.9 KB)

Example : connect a USB FDTI serial converter to main USB connector

start apps

open a terminal at 115200bps (I use Hercules terminal for ex)
send this modbus frame :

-> Slave address = 0x01 function 0x03 address 0x124D and read 16 registers (0x0010) CRC frame is 0xD169

-> check the answer

-> 0x01 slave address
-> 0x03 function 0x03
-> 0x20 is 16 registers of 2 bytes = 32 bytes
-> after is data mapped to the CStruct at 0x124D
-> 0x927A is the CRC

Have a nice day.