![]() |
EnhancedIO Exception Error
We are trying to read a potentiometer connected to our Cypress IO board using the enhancedIO class.
Here is our code so far: Code:
package edu.wpi.first.wpilibj.templates; |
Re: EnhancedIO Exception Error
Well, it's been a little while since I did Java, but I would guess that the getAnalogIn function can throw an exception, and it's not being handled. You either need a try block around it or you need to declare that it can throw the exception.
Solution 1 (in method): try { double slider = dseio.getAnalogIn(1); //additional code to execute if that works } catch (IOException ioexec) { //do stuff here if it goes wrong } (this last part may or may not be necessary; just know that it will always execute, even if an exception is thrown) finally { //more stuff that will always execute } Solution 2: public void teleopPeriodic() throws EnhancedIOException { double slider = dseio.getAnalogIn(1); } Solution 1 has much better control over what happens if an exception is thrown, so I suggest you use that one in your program. I hope it works for you. |
Re: EnhancedIO Exception Error
We tried solution 1 and it worked. Thanks for the help.
|
| All times are GMT -5. The time now is 09:41. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi