Beispiel #1
0
  @Override
  public void run() {
    ByteBuffer buffer = ByteBuffer.allocate(1);
    UsbRequest request = new UsbRequest();
    request.initialize(usbDeviceConnection, endpointIn);

    while (true) {
      request.queue(buffer, 1);
      if (usbDeviceConnection.requestWait() == request) {
        byte rxCmd = buffer.get(0);

        if (rxCmd != 0) {
          muestra = "" + rxCmd;
          temperatura = (int) rxCmd;
        }

        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
      } else {

        break;
      }
    }
  }
Beispiel #2
0
  public ZBResult readEP1(int numBytes) {
    if (usbDeviceConnection == null) return null;

    ZBResult rdo = new ZBResult();
    rdo.setStatus(ZBResultStatus.TRANSFER_OK);

    UsbRequest request = new UsbRequest();
    request.initialize(usbDeviceConnection, endpointInt);
    ByteBuffer buffer = ByteBuffer.allocate(numBytes);
    request.queue(buffer, numBytes);
    usbDeviceConnection.requestWait();
    rdo.setLength(numBytes);
    rdo.data = buffer.array();
    for (int i = 0; i < numBytes; i++) Log.d("USB" + i, rdo.data[i] + "");

    return rdo;
  }