List of usage examples for org.apache.http.util ByteArrayBuffer setLength
public void setLength(int i)
From source file:es.udc.robotcontrol.testapp.comunication.ConectorPlaca.java
public byte[] leer() { int BUFFER_LENGHT = 64; byte[] salida = new byte[BUFFER_LENGHT]; /* Read the push button status */ int result = -1; result = connection.bulkTransfer(endpointIN, salida, salida.length, 1000); Log.d(Constantes.TAG_CONECTOR, "Resultado de lectura [ " + result + " ]"); StringBuffer sb = new StringBuffer(); for (int x = 0; x < BUFFER_LENGHT; x++) { sb.append(String.valueOf(salida[x])); sb.append(" "); }/* www. j a v a 2s . co m*/ Log.i(Constantes.TAG_CONECTOR, "Leido en el cable [ " + sb.toString() + " ]"); if (result > 0) { ByteArrayBuffer bas = new ByteArrayBuffer(result); bas.append(salida, 0, result); bas.setLength(result); return bas.toByteArray(); } else { Log.i(Constantes.TAG_CONECTOR, "Resultado de lectura [ " + result + " ]"); return null; } }
From source file:es.udc.fic.android.robot_control.robot.ConectorPlaca.java
public byte[] leer() { int BUFFER_LENGHT = 64; byte[] salida = new byte[BUFFER_LENGHT]; int result = -1; result = connection.bulkTransfer(endpointIN, salida, salida.length, 1000); Log.d(C.ROBOT_TAG, "Resultado de lectura [ " + result + " ]"); StringBuffer sb = new StringBuffer(); for (int x = 0; x < BUFFER_LENGHT; x++) { sb.append(String.valueOf(salida[x])); sb.append(" "); }// w w w .j a va 2s . c o m Log.i(C.ROBOT_TAG, "Leido en el cable [ " + sb.toString() + " ]"); if (result > 0) { ByteArrayBuffer bas = new ByteArrayBuffer(result); bas.append(salida, 0, result); bas.setLength(result); return bas.toByteArray(); } else { Log.i(C.ROBOT_TAG, "Resultado de lectura [ " + result + " ]"); return null; } }