Skip to content
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

RP2040 Servo stops responding after firmata server side script killed and restart #143

Open
ale-novo opened this issue Apr 4, 2023 · 3 comments

Comments

@ale-novo
Copy link

ale-novo commented Apr 4, 2023

Hello, i have a Client RP2040 board with the ConfigurableFirmata v3.0 library installed on it, and an Python script using Perl-Firmata server side firmata library running on a PC via USB.
They both connect and communicate fine.

Ive noticed that with the RP2040 board, if i kill the script (control+c) and the re launch it, the board will re connect and communicate correctly, responds correctly to capability query, etc, but the servo no longer moves, until i recycle the power on the RP2040 board.

This does not happen with for example nano and esp8266, servo responds fine after i kill the script and re launch
also this does not happen for example with I/O, stepper, encoder, analog, etc.

For some reason only RP2040 for servo is not responding after i kill the script.

i am running the firmata close method however to be completely frank im not sure if this is being executed after control+c as this is running in a subprocess for each connected board and im doing control+c from the main thread (terminal)

  except KeyboardInterrupt:
    logger.info("Stopping board %s", name)

    # write config when killed
    #save_config(True, accelstepper_list, stepper_list, encoder_list, button_list, led_list, switch_list, pot_list, config, config_file, timed)

    # move to init position when killed (does not work)
    #for s in stepper_list:
    #  s.start_pos()
    #for s in accelstepper_list:
    #  s.start_pos()
    logger.info("Disconnecting X-Plane")
    try:
      xp.xp_disconnect()
    except:
      pass

    logger.info("Closing firmata connection")
    firmata.close()
    logger.info("Exit")
    exit(1)

could the problem be failing to execute firmata close ? or just a bug with RP2040 as this does not happen in other boards?
thanks

@pgrawehr
Copy link
Contributor

pgrawehr commented Apr 5, 2023

I have never used the servo driver, but I know that it has a number of platform-specific implementations (for instance, it is completely unsupported on ESP32), so this could indeed be a bug in the either the servo library, but also in the firmata code to handle it. A quick look at the code suggests that it should work with multiple initializations, but this needs further debugging.

@ale-novo
Copy link
Author

ale-novo commented Apr 5, 2023

Hi, thanks for your response.
ive refactored my code and i can confirm that im running firmata.close() method before exit, however for RP2040 when i re start the script w/o a power cycle the servo fails to move
is this a 'Firmata' or 'ConfigurableFirmata' problem? can you please point to the code line you suggest the problem may be in? cheers.

@pgrawehr
Copy link
Contributor

pgrawehr commented Apr 5, 2023

If the problem is in ConfigurableFirmata, the error is probably somewhere in ServoFirmata.h. I would add some logging to ServoFiirmata.attach to make sure the code behaves identically in both cases. Maybe it's also the analog message that doesn't get trough after the error. This command handler is a bit special as it relies on the pwm module.

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