RFExplorer / RFExplorer-for-Python

RF Explorer libraries and examples for Python 3
GNU Lesser General Public License v3.0
51 stars 25 forks source link

missing command: Change Module #23

Closed philipclaesson closed 2 years ago

philipclaesson commented 2 years ago

a function for changing the module using the #CM command seem to be missing in this implementation.

according to the docs:

SwitchModuleMain | #CM<0> | Request RF Explorer to enable Mainboard module where <0> is a binary 0 byte and =5 bytes

the function would look something like:

    def SendCommand_ChangeModule(self, module):
        """Set RF Explorer module (0 or 1)
        """
        assert module in [0, 1]
        self.SendCommand("CM%s" % (chr(module)))

The above function seems to do what it should, but I have also been experiencing some reliability issues that may possibly be related to the usage of the #CM command.

Is there another recommended way to change module? Any quirks that one should be aware of?

Thanks!

arocholl commented 2 years ago

Your function seems correct, not all possible commands are implemented in Python because it is very easy to use a standard SendCommand with the command you need. Basically a SendCommand("CM0") and SendCommand("CM1") do what you need.

Make sure you wait 10 seconds after changing the module before sending any new command so the internal electronics stabilize.