my todays problem is the following:
I have a network connection, at which both sides have to send commands (bytes), but my reader blocks my writer, thats how it seems to be. If I "disable" my reader (by deleting the reader from source) the writer works as he should, But when my reader is there, too, my writer just do the half of the work.
Lets say my writer has to send a command with an interval of 15 seconds and stay aware of incoming commands whach has to be answered by a little byte block. The answer block is send, but the command from the interval seems blocked.
Here my source:
protected String doInBackground(URL... params) {
try {
btw1 = (byte) sendbeg;
btw2 = (byte) w2;
btw3 = (byte) w3;
btw4 = (byte) w4;
btw5 = (byte) w5;
if (w5 == 79) {
btw6 = (byte) mins;
btw7 = (byte) seks;
btw8 = (byte) w6;
btw9 = (byte) sendend;
} else {
btw6 = (byte) w6;
btw7 = (byte) sendend;
}
SocketAddress sockaddr = new InetSocketAddress("192.168.0.7", 2001);
sock = new Socket();
int timeout = 1000; // 1000 millis = 1 second
sock.connect(sockaddr, timeout);
sock.setReuseAddress(true);
System.out.println(sock);
DataOutputStream dos = new DataOutputStream(
(OutputStream) sock.getOutputStream());
BufferedWriter wrtr = new BufferedWriter(
new OutputStreamWriter(dos), 300);
DataInputStream dis = new DataInputStream(sock.getInputStream());
BufferedReader rdr = new BufferedReader(new InputStreamReader(dis),
300);
getbyte((byte) btw1, (byte) btw2, (byte) btw3, (byte) btw4,
(byte) btw5, (byte) btw6, (byte) btw7, (byte) btw8,
(byte) btw9, (byte) btw10); //getbyte works fine, too. It's just there for putting the single bytes into an array.
System.out.println(btw.length);
dos.write(btw);
diny1 = (dis).read();
diny2 = (dis).read();
diny3 = (dis).read();
diny4 = (dis).read();
diny5 = (dis).read();
dinymin = (dis).read();
dinysek = (dis).read();
diny6 = (dis).read();
diny7 = (dis).read();
if (diny5 != 79) {
System.out.println("diny" + diny1 + " " + diny2 + " " + diny3
+ " " + diny4 + " " + diny5 + " " + dinymin + " "
+ dinysek);
} else {
if (diny7 != 5) {
diny6 = 0;
diny7 = 0;
}
System.out.println("diny" + diny1 + " " + diny2 + " " + diny3
+ " " + diny4 + " " + diny5 + " " + dinymin + " "
+ dinysek + " " + diny6 + " " + diny7);
}
dos.close();
wrtr.close();
dis.close();
rdr.close();
if (diny5 != 32) {
sendbeg = 3;
w2 = diny3;
w3 = diny2;
w4 = 48;
w5 = 32;
w6 = 11;
sendend = 5;
System.out.println(diny5 + " ^^ ");
doInBackground();
}
System.out.println("case 144-49-000.1" + context);
reccom(context);
sock.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("IO error " + e);
}
return "Done";
}
My intervalsource works fine, because it works, if the reader is inactive, so i think the problem is in this code above. please help.
You can delete the setReuseAddress() call; it's only for server sockets.
AsyncTask is not exactly the right class for your readers and writers if you stay in a loop there all the time; it would be more suitable to use Thread.
It sounds as if you need a seperate reader and writer Thread if one is not allowed to block the other.
You'll probably have to use synchronized along the way if reader and writer act independently
Related
I have created an app that receives data from a bt transmitter (Bluegiga). The readings are from EEG signals. The data rate is 1Khz (I have to admit it's high). Anyway, I acquire some data for some seconds and then the Bluetooth acts like there is no incoming data (which is not true). If I try to disconnect the Bluetooth using the app is clear that there is no more communication with the bt module at the EEG board since it doesn't respond to the desconnection (It has a led that indicates when is connected, and it doesn't turn of/on or anything).
If I decrease the data rate to (let's say 500hz) the app works ok, with some occasional 'quits', but tolerable. If I decrease it more the app works with no problems.
Of curse, by design, my app must work at 1Khz data rate so here is where the problem comes.
I have check some other post, trying to hit some kind of sns but nothing match my problem exactly (anyway I have tried to use the information on them but with no success obviously).
Sometimes I get this message, "dm_pm_timer expires", sometimes no (after the bt stops working).
Sadly there is no indication, Exception or message that can tell me what's going on.
Here is my Code for the BT reception Thread
class BluetoothReadThread extends Thread {
private final InputStream iStream;
private final OutputStream mmOutputStream;
private boolean continueReading = true;
public BluetoothReadThread() {
InputStream tmp = null;
OutputStream tmp2 = null;
try {
tmp = btSocket.getInputStream();
tmp2 = btSocket.getOutputStream();
} catch (IOException e) {
}
iStream = tmp;
mmOutputStream = tmp2;
}
#Override
public void run() {
int c;
int waitCount = 0;
while (continueReading) {
try {
if (iStream.available() > 0) {
waitCount = 0;
c = iStream.read();
readBuffer[readBufferPosition++] = c;
if (readBufferPosition == bitsExpected) {
if (bitsExpected == 22) {
ch1 = MultiplicationCombine(readBuffer[4], readBuffer[3]);
ch2 = MultiplicationCombine(readBuffer[6], readBuffer[5]);
ch3 = MultiplicationCombine(readBuffer[8], readBuffer[7]);
ch4 = MultiplicationCombine(readBuffer[10], readBuffer[9]);
ch5 = MultiplicationCombine(readBuffer[12], readBuffer[11]);
ch6 = MultiplicationCombine(readBuffer[14], readBuffer[13]);
ch7 = MultiplicationCombine(readBuffer[16], readBuffer[15]);
ch8 = MultiplicationCombine(readBuffer[18], readBuffer[17]);
} else {
ch1 = (int) filter_3((double)MultiplicationCombine(readBuffer[5], readBuffer[4], readBuffer[3]));
ch2 = (int) filter_4((double)MultiplicationCombine(readBuffer[8], readBuffer[7], readBuffer[6]));
ch3 = (int) filter_2((double)MultiplicationCombine(readBuffer[11], readBuffer[10], readBuffer[9]));
ch4 = (int) filter_2((double)MultiplicationCombine(readBuffer[14], readBuffer[13], readBuffer[12]));
ch5 = (int) filter_2((double)MultiplicationCombine(readBuffer[17], readBuffer[16], readBuffer[15]));
ch6 = (int) filter_2((double)MultiplicationCombine(readBuffer[20], readBuffer[19], readBuffer[18]));
ch7 = (int) filter_2((double)MultiplicationCombine(readBuffer[23], readBuffer[22], readBuffer[21]));
ch8 = (int) filter_2((double)MultiplicationCombine(readBuffer[26], readBuffer[25], readBuffer[24]));
}
Header_int = readBuffer[0];
PK_ID_int = readBuffer[1];
PK_Counter_int = readBuffer[2];
if (downsample++ == downsample_value) {
addEntry(ch1 / scaCh1, ch2 / scaCh2, ch3 / scaCh3, ch4 / scaCh4, ch5 / scaCh5, ch6 / scaCh6, ch7 / scaCh7, ch8 / scaCh8);
downsample = 0;
}
//ProgrNum,PacketType,Ch1,Ch2,Ch3,Ch4,Ch5,Ch6,Ch7,Ch8,MRK
if (write_open) {
osw.write(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + "," + bolOpenClose + "\n");
//osw.write(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + "," + "\n");
}
System.out.println(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + ", AV=" + iStream.available() );
mmOutputStream.write(valueSTR.getBytes());
// if(downsample++==14) { safe_copy(readBuffer); plot=true; downsample=0;}
readBufferPosition = 0;
try {
Thread.sleep(3);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} catch (IOException e) {
System.out.println(e + "\nError sending data + :" + e);
// Bluetooth error! Stop reading.
//this.stopAndSendIntent();
}
}
}
/*
public void stopAndSendIntent() {
this.cancel();
Intent intent = new Intent();
intent.setAction(BLUETOOTH_ACTION_DONE_READING);
sendBroadcast(intent);
}
*/
public void cancel() {
System.out.println("-----Cancelling readThread!!");
try {
iStream.close();
} catch (IOException e) {
} catch (NullPointerException e) {
}
;
continueReading = false;
}
}
It works like this:
I read a received character (c=iStream.read()).
Then I copy this character to an int array until I reach the length of the packet (it can be 22 or 28 (bitsExpected)).
The following part is just filtering and plotting of the signal.
I have tried many other implementations but I get the same result.
Even if I eliminate the part of the filtering and plotting (just reading data) the problem persists.
If instead of working with array, I work with string, i.e, using append() (which should be the same?) I manage to get an working connection (no quits) but, as soon as I manipulate the program using the array everything is the same.
I'm stuck with this for 1 month already, so I will really appreciate any comments, past experience or suggestions.
Thanks in advance.
I just added this piece of code
if (PK_Counter_int % 100 == 0) mmOutputStream.write(startTring.getBytes());
and it works just fine so far.
I am writing an Android application in which I am using Jackrabbit WebDAV Library.
With help of this WebDAV library, I can download and upload files from and to server. This works as expected.
Now I want to get a byte array from file with specific offset from the server. For this what I have tried is:
byte buffer[] = null;
Log.d(TAG, "downloadBytes '" + fileUri + "' byteOffset '" + byteOffset + "' byteOffset '" + byteCount);
HttpClient httpClient = new HttpClient();
GetMethod httpMethod = new GetMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
String bytesMessage = "bytes=" + byteOffset + "-" + total;
Log.d(TAG, "bytesMessage " + bytesMessage);
httpMethod.addRequestHeader("Range", bytesMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpClient.executeMethod(httpMethod);
This works as expected.
Similarly, I want to update file on server with byte array by specifying offset, but this doesn't appear to work; the server returns a 400 Bad Request error code.
byte buffer[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50};
Log.d(TAG, "downloadBytes '" + fileUri + "' byteOffset '" + byteOffset + "' byteCount '" + byteCount);
HttpClient httpClient = new HttpClient();
PutMethod httpMethod = new PutMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
String bytesMessage = "bytes=" + byteOffset + "-" + total;
Log.d(TAG, "bytesMessage " + bytesMessage);
httpMethod.addRequestHeader("Range", bytesMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpMethod.addRequestHeader("Overwrite", "T");
InputStream is = new ByteArrayInputStream(buffer);
RequestEntity requestEntity = new InputStreamRequestEntity(is, "text/plain");
httpMethod.setRequestEntity(requestEntity);
httpClient.executeMethod(httpMethod);
What am I missing in the request header?
Following are correct headers, using this I am able update webdav server resources with offset and byte length.
HttpClient httpClient = new HttpClient();
PutMethod httpMethod = new PutMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
int range = total-1;
String rangeMessage = "bytes=" + byteOffset +"-" + range;
Log.d(TAG, "rangeMessage " + rangeMessage);
String lengthMessage = Integer.toString(byteCount);
String contentRangeMessage = "bytes " + byteOffset +"-" + range + "/*";
Log.d(TAG, "contentRangeMessage " + contentRangeMessage);
Log.d(TAG, "lengthMessage " + lengthMessage);
httpMethod.addRequestHeader("Content-Length", lengthMessage);
httpMethod.addRequestHeader("Content-Range", contentRangeMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpMethod.addRequestHeader("Overwrite", "T");
private void sendData(String message) {
byte[] msgBuffer = message.getBytes();
Log.d(TAG, "...Send data: " + message + "...");
try {
outStream.write(msgBuffer);
} catch (IOException e) {
String msg = "In onResume() and an exception occurred during write: "
+ e.getMessage();
if (address.equals("00:00:00:00:00:00"))
msg = msg
+ ".\n\nUpdate your server address from 00:00:00:00:00:00 to the correct address on line 35 in the java code";
msg = msg + ".\n\nCheck that the SPP UUID: " + MY_UUID.toString()
+ " exists on server.\n\n";
errorExit("Fatal Error", msg);
}
}
In the above code we can send data like just "0" and "1". But want to send in 8-bits like 00000000 and 00000001. It should display in Arduino board. If press to send data 1 it should show 00000001 and 00000000.
Use this:
String str = "25789";
int i = Integer.parseInt(str);
String binarystr = Integer.toBinaryString(i);
char[] buffer = new char[binarystr.length()];
binarystr.getChars(0,binarystr.length(), buffer, 0);
System.out.println("char array:: "+Arrays.toString(buffer));
byte[] binaryFormat = getbyteFromString(buffer);
for (byte b : binaryFormat) {
System.out.println(Integer.toBinaryString(b & 255 | 256).substring(1));
}
method:
private byte[] getbyteFromString(char[] binarystr){
int length = binarystr.length/8;
if(binarystr.length % 8 > 0)
length++;
int iterationCount = length ;
byte[] binaryFormat = new byte[iterationCount];
int iter = iterationCount - 1;
for(int i = binarystr.length - 1; i >=0 ;){
byte byt = 0x0;
for(int j = 0; j < 8 ; j++){
if(i < 0)
break;
int b = binarystr[i] - 48;
byt = (byte) (byt + (b << j));
i--;
}
binaryFormat[iter] = byt;
iter--;
}
return binaryFormat;
}
I've been looking around and unfortunately the android ibeacon library has been deprecated, so I am attempting to do this native. I have implemented the BluetoothAdapter.LeScanCallback and the built in onLeScan() method that will fire when a device is picked up. I would like to read in that device's ProximityUUID, major and minor characteristics and identifier. I'm not sure how to get that information out of the Android object BluetoothDevice.
How do I extract that information (ProximityUUID, major, minor, & identifier characteristics) from the Android BluetoothDevice, or is there another way to do it?
Thanks!
you can refer this post to fully understand what those bytes means in LeScanCallback .
And this is my code to parse all information needed:
// an object with all information embedded from LeScanCallback data
public class ScannedBleDevice implements Serializable {
// public BluetoothDevice BLEDevice;
/**
* Returns the hardware address of this BluetoothDevice.
* <p>
* For example, "00:11:22:AA:BB:CC".
*
* #return Bluetooth hardware address as string
*/
public String MacAddress;
public String DeviceName;
public double RSSI;
public double Distance;
public byte[] CompanyId;
public byte[] IbeaconProximityUUID;
public byte[] Major;
public byte[] Minor;
public byte Tx;
public long ScannedTime;
}
// use this method to parse those bytes and turn to an object which defined proceeding.
// the uuidMatcher works as a UUID filter, put null if you want parse any BLE advertising data around.
private ScannedBleDevice ParseRawScanRecord(BluetoothDevice device,
int rssi, byte[] advertisedData, byte[] uuidMatcher) {
try {
ScannedBleDevice parsedObj = new ScannedBleDevice();
// parsedObj.BLEDevice = device;
parsedObj.DeviceName = device.getName();
parsedObj.MacAddress = device.getAddress();
parsedObj.RSSI = rssi;
List<UUID> uuids = new ArrayList<UUID>();
int skippedByteCount = advertisedData[0];
int magicStartIndex = skippedByteCount + 1;
int magicEndIndex = magicStartIndex
+ advertisedData[magicStartIndex] + 1;
ArrayList<Byte> magic = new ArrayList<Byte>();
for (int i = magicStartIndex; i < magicEndIndex; i++) {
magic.add(advertisedData[i]);
}
byte[] companyId = new byte[2];
companyId[0] = magic.get(2);
companyId[1] = magic.get(3);
parsedObj.CompanyId = companyId;
byte[] ibeaconProximityUUID = new byte[16];
for (int i = 0; i < 16; i++) {
ibeaconProximityUUID[i] = magic.get(i + 6);
}
if (uuidMatcher != null) {
if (ibeaconProximityUUID.length != uuidMatcher.length) {
Log.e(LOG_TAG,
"Scanned UUID: "
+ Util.BytesToHexString(
ibeaconProximityUUID, " ")
+ " filtered by UUID Matcher "
+ Util.BytesToHexString(uuidMatcher, " ")
+ " with length requirment.");
return null;
}
for (int i = 0; i < 16; i++) {
if (ibeaconProximityUUID[i] != uuidMatcher[i]) {
Log.e(LOG_TAG,
"Scanned UUID: "
+ Util.BytesToHexString(
ibeaconProximityUUID, " ")
+ " filtered by UUID Matcher "
+ Util.BytesToHexString(uuidMatcher,
" "));
return null;
}
}
}
parsedObj.IbeaconProximityUUID = ibeaconProximityUUID;
byte[] major = new byte[2];
major[0] = magic.get(22);
major[1] = magic.get(23);
parsedObj.Major = major;
byte[] minor = new byte[2];
minor[0] = magic.get(24);
minor[1] = magic.get(25);
parsedObj.Minor = minor;
byte tx = 0;
tx = magic.get(26);
parsedObj.Tx = tx;
parsedObj.ScannedTime = new Date().getTime();
return parsedObj;
} catch (Exception ex) {
Log.e(LOG_TAG, "skip one unknow format data...");
// Log.e(LOG_TAG,
// "Exception in ParseRawScanRecord with advertisedData: "
// + Util.BytesToHexString(advertisedData, " ")
// + ", detail: " + ex.getMessage());
return null;
}
}
Payloads of advertising packets should be parsed as a list of AD structures.
iBeacon is a kind of AD structures.
See "iBeacon as a kind of AD structures" for details. Also, see an answer to a similar question.
I try to write a program to read all the sector of NCF tag.So when I run the test :
the tag is detected
I get the tag Id
I get the number of sector
But i can only read the first sector !
Here my code :
public class MainActivity extends Activity {
public String TAG_LOCAL = "Home - ";
public boolean MODE_DEBUG_LOCAL = true;
NfcAdapter nfcAdapter;
PendingIntent pendingIntent;
IntentFilter[] intentFilter;
String[][] generalTechLists;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.w("ISI", "Main Start");
//detect if NFC device
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
Log.w("ISI", "NFC detected");
}else{
Log.w("ISI", "NFC NOT detected");
}
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
try {
ndef.addDataType("*/*");
} catch (MalformedMimeTypeException e) {
Log.w("ISI", " error ndef = " + e.getMessage());
}
intentFilter = new IntentFilter[] {ndef};
generalTechLists = new String[][] { new String[] { MifareClassic.class.getName() } };
nfcAdapter = NfcAdapter.getDefaultAdapter(this);
pendingIntent = PendingIntent.getActivity(this, 0,new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
}
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
resolveIntent(intent);
}
void resolveIntent(Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
//Identifiant du tag NFC
byte[] byte_id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
Log.w("ISI", "Tag id = " + ByteArrayToHexString(byte_id));
//techno disponible
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList = tagFromIntent.getTechList();
for (int Cpt = 0; Cpt <techList.length; Cpt++){
Log.w("ISI", "Techno = " + techList[Cpt]);
}
//QUESTION A POSER DANS XDA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MifareClassic mfc = MifareClassic.get(tagFromIntent);
try{
mfc.connect();
int size = mfc.getSize();
Log.w("ISI", "size (byte) = " + size);
int nbrSector = mfc.getSectorCount();
Log.w("ISI", "NbrSector = " + nbrSector);
for (int Cpt = 0; Cpt < nbrSector; Cpt++){
boolean auth = mfc.authenticateSectorWithKeyA(Cpt, MifareClassic.KEY_DEFAULT);
if (auth){
int nbrBlock = mfc.getBlockCountInSector(Cpt);
Log.w("ISI", "NbrBlock = " + nbrBlock + " for sector " + Cpt);
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(k);
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
}else{
Log.w("ISI", " Impossible to connect at sector " + Cpt);
}
}
}catch(IOException e){
Log.w("ISI", " error = " + e.getMessage());
}
}// End of method
}
#Override
protected void onResume() {
super.onResume();
nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilter, generalTechLists);
}
private String getHexString(String hex){
StringBuilder output = new StringBuilder();
for (int i = 0; i < hex.length(); i+=2) {
String str = hex.substring(i, i+2);
output.append((char)Integer.parseInt(str, 16));
}
return output.toString();
}
String ByteArrayToHexString(byte[] inarray) {
//Thanks Adam Laurie sur XDA
int i, j, in;
String [] hex = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
String out= "";
for(j = 0 ; j < inarray.length ; ++j) {
in = (int) inarray[j] & 0xff;
i = (in >> 4) & 0x0f;
out += hex[i];
i = in & 0x0f;
out += hex[i];
}
return out;
}
}
And here the log :
Tag id = C44F0EDD
Techno = android.nfc.tech.MifareClassic
Techno = android.nfc.tech.NfcA
Techno = android.nfc.tech.NdefFormatable
size (byte) = 1024
NbrSector = 16
NbrBlock = 4 for sector 0
Block num 0 - data C44F0EDD58880400C185149849803612
Block num 1 - data 00000000000000000000000000000000
Block num 2 - data 00000000000000000000000000000000
Block num 3 - data 000000000000FF078069FFFFFFFFFFFF
NbrBlock = 4 for sector 1
error = Tag was lost.
So I don't understand what happens.
Thank for help
Try to change:
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(k);
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
with this
byte[] data = mfc.readBlock(bIndex);
for (int k = 0; k < nbrBlock; k++){
bIndex = mfc.sectorToBlock(Cpt);
bIndex++;
Log.w("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
}
from: http://mifareclassicdetectiononandroid.blogspot.it/
Set your code like this:
int bIndex = 0;
try{
mfc.connect();
int size = mfc.getSize();
Log.i("ISI", "size (byte) = " + size);
int sectorCount = mfc.getSectorCount();
Log.i("ISI", "NbrSector = " + sectorCount);
for (int Cpt = 0; Cpt < sectorCount; Cpt++){
boolean auth = mfc.authenticateSectorWithKeyA(Cpt, MifareClassic.KEY_DEFAULT);
if (auth){
int nbrBlock = mfc.getBlockCountInSector(Cpt);
Log.i("ISI", "NbrBlock = " + nbrBlock + " for sector " + Cpt);
for (int k = 0; k < nbrBlock; k++){
byte[] data = mfc.readBlock(bIndex);
Log.i("ISI", "Block num " + k + " - data " + ByteArrayToHexString(data));
bIndex++;
}
}else{
Log.i("ISI", " Impossible to connect at sector " + Cpt);
}
}
}catch(IOException e){
Log.i("ISI", " error = " + e.getMessage());
}