Wednesday, 21 August 2013

getchars() sequence off by 1byte

getchars() sequence off by 1byte

I set up a test example of getchars() call and the returns the bytes are
off sequence by 1. byte [] readBufA = new byte [] {1,2,3,4,5,6,7}; Test
array
I then run the getchar and the result is off by 1.
String strIncom = new String(readBufA, 0, 7);
// create string from bytes array
// String strIncom = new String(readBuf, 0, msg.arg1);
// create string from bytes array
sb.append(strIncom); // append string
int counter = sb.length(); // Get length of string
if (counter == 7){
getChars(0,7,readBufA,0);
Log.d(TAG, "Data " + sb + " Size " + (char)readBuf[0] + " " +
(char)readBuf[1] + " " + (char)readBuf[2] + " " + (char)readBuf[3] + " " +
(char)readBuf[4] + " " + (char)readBuf[5] + " " + (char)readBuf[6] +" " +
(char)readBuf[7]+ " " + counter);// receive massage
The log.d retuns (2,3,4,5,6,7,-,-,7) counter is correct but dont see the
correct return

No comments:

Post a Comment