Skip to content

saveNetwork and saveRegisters returns None #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlexisTM opened this issue May 17, 2017 · 6 comments
Closed

saveNetwork and saveRegisters returns None #28

AlexisTM opened this issue May 17, 2017 · 6 comments

Comments

@AlexisTM
Copy link

Dear,

The functions local_device.saveNetwork and local_deviceRegisters are returning None instead of the POZYX_SUCCESS or POZYX_FAILURE.

@AlexisTM
Copy link
Author

With the current master a9cad47

While calling saveNetwork. The same saveRegisters Nonetype is now crashing the command.

Traceback (most recent call last):
  File "/home/alexis/scripts/setup_anchors.py", line 88, in <module>
    set_anchor_configuration()
  File "/home/alexis/scripts/setup_anchors.py", line 63, in set_anchor_configuration
    pozyx.saveNetwork(remote_id=tag)
  File "/usr/local/lib/python2.7/dist-packages/pypozyx/lib.py", line 1515, in saveNetwork
    status &= self.saveRegisters([POZYX_POS_NUM_ANCHORS], remote_id=remote_id)
TypeError: unsupported operand type(s) for &=: 'int' and 'NoneType'

@AlexisTM
Copy link
Author

Solved by replacing:

    def saveRegisters(self, registers, remote_id=None):
        """
        Saves the given registers to the Pozyx's flash memory, if these are writable registers.

        This means that upon reset, the Pozyx will use these saved values instead of the default values.
        This is especially practical when changing UWB settings of an entire network, making it unnecessary
        to re - set these when resetting or repowering a device.

        DISCLAIMER: Make sure to not abuse this function in your code, as the flash memory only has a finite
        number of writecycles available, adhere to the Arduino's mentality in using flash memory.

        Args:
            registers: Registers to save to the flash memory. Data([register1, register2, ...]) or [register1, register2, ...]
                These registers have to be writable. Saving the UWB gain is currently not working.

        Kwargs:
            remote_id: Remote Pozyx ID.

        Returns:
            POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
        """
        self.saveConfiguration(
            POZYX_FLASH_REGS, registers, remote_id)

by:

    def saveRegisters(self, registers, remote_id=None):
        """
        Saves the given registers to the Pozyx's flash memory, if these are writable registers.

        This means that upon reset, the Pozyx will use these saved values instead of the default values.
        This is especially practical when changing UWB settings of an entire network, making it unnecessary
        to re - set these when resetting or repowering a device.

        DISCLAIMER: Make sure to not abuse this function in your code, as the flash memory only has a finite
        number of writecycles available, adhere to the Arduino's mentality in using flash memory.

        Args:
            registers: Registers to save to the flash memory. Data([register1, register2, ...]) or [register1, register2, ...]
                These registers have to be writable. Saving the UWB gain is currently not working.

        Kwargs:
            remote_id: Remote Pozyx ID.

        Returns:
            POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
        """
        return self.saveConfiguration(
            POZYX_FLASH_REGS, registers, remote_id)

@AlexisTM
Copy link
Author

AlexisTM commented Oct 4, 2017

@laurentva

@laurentva
Copy link
Collaborator

Hey Alexis,

Sorry for the long wait! I'm working with the Python library this week so I'll be catching up on maintenance and put a new version on PyPi

@laurentva
Copy link
Collaborator

Fixed in develop, will merge into master and release after testing

@AlexisTM
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants