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
* @author ricky barrette
*/
public void loop() throws ConnectionLostException;
public void loop() throws ConnectionLostException, InterruptedException;
/**
* Called when the IOIO is disconnected.

View File

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