IOIOListener.java

added throws InterruptedException to loop()

IOIOThread.java
added a catch for InterruptedException in run()
removed catch for Exception in run()
added a catch for IncompatibilityException in run()
added Loging
This commit is contained in:
2012-01-28 15:24:52 -05:00
parent 4fcb1cffa2
commit aef0901a07
2 changed files with 12 additions and 5 deletions

View File

@@ -42,7 +42,7 @@ public interface IOIOListener {
* Here you want to update the ports * Here you want to update the ports
* @author ricky barrette * @author ricky barrette
*/ */
public void loop() throws ConnectionLostException; public void loop() throws ConnectionLostException, InterruptedException;
/** /**
* Called when the IOIO is disconnected. * Called when the IOIO is disconnected.

View File

@@ -21,10 +21,12 @@
*/ */
package com.TwentyCodes.android.ioio; package com.TwentyCodes.android.ioio;
import android.util.Log;
import ioio.lib.api.DigitalOutput; import ioio.lib.api.DigitalOutput;
import ioio.lib.api.IOIO; import ioio.lib.api.IOIO;
import ioio.lib.api.IOIOFactory; import ioio.lib.api.IOIOFactory;
import ioio.lib.api.exception.ConnectionLostException; import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.api.exception.IncompatibilityException;
/** /**
* This is the thread that maintains the IOIO interaction. * This is the thread that maintains the IOIO interaction.
@@ -40,7 +42,8 @@ import ioio.lib.api.exception.ConnectionLostException;
*/ */
public class IOIOThread extends Thread{ public class IOIOThread extends Thread{
private IOIO mIOIO; private static final String TAG = "IOIOThread";
private IOIO mIOIO;
private boolean isAborted = false; private boolean isAborted = false;
private long mUpdateInterval = 10; private long mUpdateInterval = 10;
private boolean isStatLedEnabled = false; private boolean isStatLedEnabled = false;
@@ -127,12 +130,16 @@ public class IOIOThread extends Thread{
} }
} catch (ConnectionLostException e) { } catch (ConnectionLostException e) {
mListener.onDisconnected(); mListener.onDisconnected();
} catch (Exception e) { } catch (InterruptedException e) {
e.printStackTrace(); Log.e(TAG, e.getMessage());
e.printStackTrace();
mIOIO.disconnect(); mIOIO.disconnect();
mListener.onDisconnected(); mListener.onDisconnected();
break; break;
} finally { } catch (IncompatibilityException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
} finally {
try { try {
mIOIO.waitForDisconnect(); mIOIO.waitForDisconnect();
mListener.onDisconnected(); mListener.onDisconnected();