pyhys/minimalmodbus

How to send a non-standard function code

larrybarello opened this issue · 2 comments

For a particular vendor, a custom function code ($78) with a payload of 0x0000, 0x0001, causes a reset to factory defaults. The response appears to be an echo of the request.

Is this possible without modifying minimalmodbus code?

i'm a newbie and attempted a subclass, and ran into trouble pretty quick when making a stripped down "read" method that just jammed in the values.

Could a generic write be exposed and allow the user jam in OEM functions? Or maybe a magic method that overrides the function code on the next transaction? Then the user can pick the closest transaction, override the function code. In my case "read_register(0)" and poke in the $78 This is an ugly solution, but presumably the user would know what they are doing if they tried it.

edit: this particular vendor also uses 0xFF as the broadcast address :(

pyhys commented

Hi!
It is possible to use the _perform_command() functionality as described in
https://minimalmodbus.readthedocs.io/en/stable/develop.html#extending-minimalmodbus

Note that it is outside the official API and is subject to future changes.