예제 #1
0
  /** 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) {
        }
      }
    }
  }
 /** 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) {
       }
     }
   }
 }
예제 #3
0
 /** Not relevant to subclasses. */
 public final synchronized void abort() {
   abort_ = true;
   if (ioio_ != null) {
     ioio_.disconnect();
   }
   if (connected_) {
     interrupt();
   }
 }