robotpy / robotpy-wpilib

Moved to https://github.com/robotpy/mostrobotpy
https://robotpy.github.io
Other
169 stars 59 forks source link

Running LiveWindow after calling free() on a resource results in "operation on freed port" errors. #148

Closed computer-whisperer closed 8 years ago

computer-whisperer commented 9 years ago

There doesn't seem to be a mechanism for removing components from LiveWindow after they have been freed. I'm not quite sure how this should be handled.

One way would be to add a removeComponent() method to LiveWindow and have every free() method call it. Another way (possibly a good idea to do in any case) would be to have LiveWindow catch and log exceptions that it receives from the device objects.

@virtuald, @PeterJohnson what do you think?

virtuald commented 9 years ago

What's the use case here?

computer-whisperer commented 9 years ago

If at any time in your program you do this:

mymotor = wpilib.Talon(0)
mymotor.free()

After this, any attempts to enable LiveWindow will crash the DS thread, since it will try to run mymotor.set(0) after mymotor has been freed

computer-whisperer commented 9 years ago

bump?

virtuald commented 9 years ago

Sorry, sounds like (as usual) you have a good point here. I'm not really planning on working on RobotPy until ~Septemberish, but feel free to make a PR to fix this.

I imagine this probably affects WPILib itself too, yes?

computer-whisperer commented 9 years ago

Yes, i think it would affect upstream. When i fix it, do you think it would be important to try and push something to Java WPILib? Or should we wait to see what changes they plan on making for the 2016 season?

virtuald commented 9 years ago

If you feel like pushing it upstream, I imagine that would be a good thing. You can either apply for an account on the WPILib collab.net site and submit a branch via gerrit, or you can do a pull request to our allwpilib repository and I can submit the branch for you.