Modbus Library - Support for custom fcodes?


#1

I’m working on interfacing with a modbus sensor via UART and want to leverage the EI Modbus libraries.

The sensor I am using uses custom function codes that are outside of the support of the existing library. Any advice on implementing custom fcodes outside of cloning and modifying these libraries?

What I am finding is the modbus predefined message types (coil, diagnostic, etc) are heavily integrated into the modbusmaster and modbus485 libraries which makes it inflexible and difficult to modify without breaking things.

Thanks!


#2

I’m sorry for the delayed response. Our Modbus implementation is tied to the Modbus RTU specification, which specifies all the used function codes. If you need to modify the library implementation I would highly recommend to use the latest official library version through #require, extend it in your application and redefine the behavior that you need. If it doesn’t work then unfortunately the only way is to fork the EI implementation.