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

odrive.save_configuration() fails when called 3 or more times. #183

Open
Nate711 opened this Issue Jun 23, 2018 · 1 comment

Comments

2 participants
@Nate711
Contributor

Nate711 commented Jun 23, 2018

The save_configuration() function of the python odrive library fails if you call it 3 or more times.

It seems that in these cases, only the first change is saved permanently. The code below reproduces the problem by changing the brake_resistance 3 times and saving after each change. Even though the last change sets the brake_resistance to 2.0, the odrive will say the brake_resistance is still 0.0.

CODE:

import odrive 
from fibre import Logger, Event
from odrive.utils import OperationAbortedException
from fibre.protocol import ChannelBrokenException

def get_odrive(shutdown_token):
    print('Looking for ODrive...',end='')
    odrv = odrive.find_any(search_cancellation_token=app_shutdown_token, channel_termination_token=app_shutdown_token)
    print('Found.')
    return odrv

def reboot_odrive(odrv):
    """
    Reboot odrive
    """
    try:
        odrv.reboot()
    except ChannelBrokenException:
        print('Lost connection because of reboot...')

app_shutdown_token = Event()
try:
    odrv0 = get_odrive(app_shutdown_token)
    print('Erasing configuration...',end='')
    odrv0.erase_configuration()
    print('Done.')
    reboot_odrive(odrv0)
    odrv0 = get_odrive(app_shutdown_token)

    print('*** Calling save_configuration() 3 times...',end='')
    odrv0.config.brake_resistance = 0.0
    odrv0.save_configuration()
    odrv0.config.brake_resistance = 1.0
    odrv0.save_configuration()
    odrv0.config.brake_resistance = 2.0
    odrv0.save_configuration()
    odrv0.config.brake_resistance = 3.0
    odrv0.save_configuration()
    print('Done.')

    reboot_odrive(odrv0)

    odrv0 = get_odrive(app_shutdown_token)
    print('Brake resistance (should be 2.0): ',end='')
    print(odrv0.config.brake_resistance)

except OperationAbortedException:
    logger.info("Operation aborted.")
finally:
    app_shutdown_token.set()

@madcowswe madcowswe added this to TODO in ODrive Development Jun 23, 2018

@madcowswe

This comment has been minimized.

Owner

madcowswe commented Jul 17, 2018

Until we fix this, the current workaround is to only save configuration once per boot. I know this is inconvenient, but as far as we know it will at least correctly save your config. To make sure you don't lose any configs you set: for now reboot after every save_configuration()

Capo01 added a commit to Capo01/ODrive that referenced this issue Aug 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment