Closed Julien-Faure closed 2 years ago
What is the special function you want to add? You could of course just clone, add the code and create an MR if you're confident it will be good for the library
I wanted to know how to add custom function.
Read registers or write registers value are official functions.
I want to create a function with id 80.
This function could reboot a remote slave.
ModbusMaster is an aggregate of other public classes that can do this if you use them directly. I would like to say that I can provide this as a feature of j2mod out of the box but I don't have time I'm afraid. Take a look at some of the examples under com.ghgande.j2mod.modbus.cmd for more concrete help
Me and @huseyinsaht currently face the same problem and I implemented a quick prototype that supports a specific Function Code 0x40. See this commit: https://github.com/sfeilmeier/j2mod/commit/449fabd56305639f59a630a2f2d9fa01e7439ede
Unfortunately the instantiation of the Request/Reponse objects happens in a static method inside ModbusRequest
so we can only solve it by forking the library. It might be a good idea to refactor this method to allow providing a dynamic factory object that creates these objects at runtime.
@steveohara: Would this be an approach you would accept as a pull-request contribution or would you take another way?
I would to add special function in ModbusMaster, can you help me please ?
Thank you in advance.