/** Not relevant to subclasses. */ @Override public final void run() { super.run(); while (true) { try { synchronized (this) { if (abort_) { break; } ioio_ = IOIOFactory.create(); } ioio_.waitForConnect(); setup(); while (true) { loop(); } } catch (ConnectionLostException e) { if (abort_) { break; } } catch (Exception e) { Log.e("AbstractIOIOActivity", "Unexpected exception caught", e); ioio_.disconnect(); break; } finally { try { ioio_.waitForDisconnect(); } catch (InterruptedException e) { } } } }
public void run() { try { switch (m_Task) { case Connect: m_IOIO.waitForConnect(); IOIOInterface.OnIOIOConnected(); break; case Disconnect: m_IOIO.waitForDisconnect(); IOIOInterface.OnIOIODisconnected(); break; } } catch (ConnectionLostException e) { IOIOInterface.Log("Lost connection during IOIOWaitThread (" + m_Task + ")"); IOIOInterface.OnIOIODisconnected(); } catch (IncompatibilityException e) { IOIOInterface.Log("Incompatibility detected during IOIOWaitThread (" + m_Task + ")"); IOIOInterface.OnIOIOIncompatible(); } catch (InterruptedException e) // This one is most likely our own doing { } }
/** Not relevant to subclasses. */ @Override public final void run() { super.run(); Looper.prepare(); while (true) { try { synchronized (this) { if (abort_) { break; } ioio_ = IOIOFactory.create(spec_.className, spec_.args); } ioio_.waitForConnect(); connected_ = true; setup(); while (!abort_) { loop(); } ioio_.disconnect(); } catch (ConnectionLostException e) { RunningScreen.piezoSignal = false; if (abort_) { break; } } catch (InterruptedException e) { ioio_.disconnect(); break; } catch (IncompatibilityException e) { Log.e(TAG, "Incompatible IOIO firmware", e); incompatible(); // nothing to do - just wait until physical disconnection try { ioio_.waitForDisconnect(); } catch (InterruptedException e1) { ioio_.disconnect(); } } catch (Exception e) { System.out.println("in exception handler"); Log.e(TAG, "Unexpected exception caught", e); ioio_.disconnect(); break; } finally { try { if (ioio_ != null) { ioio_.waitForDisconnect(); if (connected_) { disconnected(); } } } catch (InterruptedException e) { } } } }