private int readByte(Command command,int value,int index,boolean signed) throws LibUsbException, UsbException {
  if (mDeviceHandle != null) {
    ByteBuffer buffer=ByteBuffer.allocateDirect(1);
    int transferred=LibUsb.controlTransfer(mDeviceHandle,USB_REQUEST_IN,command.getValue(),(short)value,(short)index,buffer,USB_TIMEOUT_MS);
    if (transferred < 0) {
      throw new LibUsbException("read error",transferred);
    }
    byte result=buffer.get(0);
    if (signed) {
      return (result & 0xFF);
    }
 else {
      return result;
    }
  }
 else {
    throw new LibUsbException("device handle is null",LibUsb.ERROR_NO_DEVICE);
  }
}

private int readByte ( Command command , int value , int index , boolean signed ) throws LibUsbException , UsbException { if ( mDeviceHandle != null ) { ByteBuffer buffer = ByteBuffer . allocateDirect ( 1 ) ; int transferred = LibUsb . controlTransfer ( mDeviceHandle , USB_REQUEST_IN , command . getValue ( ) , ( short ) value , ( short ) index , buffer , USB_TIMEOUT_MS ) ; if ( transferred < 0 ) { throw new LibUsbException ( "read error" , transferred ) ; } byte result = buffer . get ( 0 ) ; if ( signed ) { return ( result & 0xFF ) ; } else { return result ; } } else { throw new LibUsbException ( "device handle is null" , LibUsb . ERROR_NO_DEVICE ) ; } }
reads a single byte value from the device .
