Android Open Source - SmartCocktailShaker Usb Serial Input Stream






From Project

Back to project page SmartCocktailShaker.

License

The source code is released under:

MIT License

If you think the Android project SmartCocktailShaker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hoho.android.usbserial.util;
/*from w w  w. j a  v a 2  s.  c  om*/
import java.io.IOException;
import java.io.InputStream;

import com.hoho.android.usbserial.driver.UsbSerialDriver;

public class UsbSerialInputStream extends InputStream {

  private UsbSerialDriver driver = null;
  
  private int timeoutMillis;
  
  public UsbSerialInputStream(UsbSerialDriver driver) {
    this(driver, 1000);
  }
  
  public UsbSerialInputStream(UsbSerialDriver driver, int timeoutMillis) {
    this.driver = driver;
    this.timeoutMillis = timeoutMillis;
  }
  
  @Override
  public int read() throws IOException {
    byte[] buffer = new byte[1];
    return driver.read(buffer, timeoutMillis);
  }
  
  @Override
  public int read(byte[] b) throws IOException {
    return driver.read(b, timeoutMillis);
  }
  
  @Override
  public int read(byte[] b, int off, int len) throws IOException {
    byte[] buffer = new byte[len];
    int n = driver.read(buffer, timeoutMillis);
    if (n > 0) {
      System.arraycopy(buffer, 0, b, off, n);
    }
    return n;
  }
  
  @Override
  public void close() throws IOException {
    driver.close();
  }

}




Java Source Code List

com.hoho.android.usbserial.driver.CdcAcmSerialDriver.java
com.hoho.android.usbserial.driver.CommonUsbSerialDriver.java
com.hoho.android.usbserial.driver.Cp2102SerialDriver.java
com.hoho.android.usbserial.driver.FtdiSerialDriver.java
com.hoho.android.usbserial.driver.ProlificSerialDriver.java
com.hoho.android.usbserial.driver.UsbId.java
com.hoho.android.usbserial.driver.UsbSerialDriver.java
com.hoho.android.usbserial.driver.UsbSerialProber.java
com.hoho.android.usbserial.driver.UsbSerialRuntimeException.java
com.hoho.android.usbserial.util.HexDump.java
com.hoho.android.usbserial.util.SerialInputOutputManager.java
com.hoho.android.usbserial.util.UsbSerialInputStream.java
com.hoho.android.usbserial.util.UsbSerialOutputStream.java
com.tonydicola.smartshaker.BluetoothSppProvider.java
com.tonydicola.smartshaker.JsonDrinkProvider.java
com.tonydicola.smartshaker.MockConnectionProvider.java
com.tonydicola.smartshaker.PrepareDrinkModel.java
com.tonydicola.smartshaker.StepListAdapter.java
com.tonydicola.smartshaker.UsbSerialProvider.java
com.tonydicola.smartshaker.activities.ChooseConnection.java
com.tonydicola.smartshaker.activities.DrinkDetails.java
com.tonydicola.smartshaker.activities.DrinkList.java
com.tonydicola.smartshaker.activities.PrepareDrink.java
com.tonydicola.smartshaker.factories.ConnectionFactory.java
com.tonydicola.smartshaker.factories.DrinkFactory.java
com.tonydicola.smartshaker.interfaces.ConnectionProvider.java
com.tonydicola.smartshaker.interfaces.DeviceConnection.java
com.tonydicola.smartshaker.interfaces.DrinkProvider.java
com.tonydicola.smartshaker.interfaces.Drink.java
com.tonydicola.smartshaker.interfaces.PreparationStep.java