X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosUsb.java;h=e559f8141718d3b33d01045b62531a90526bc78f;hp=4685a82470cae609161714d66d53f053ea5a56f4;hb=2509b664df6a13e6ae9e6753dc9fa0d696a4f6c7;hpb=bca342577740a9d04b8419ecadcff582e77f1e61 diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java index 4685a824..e559f814 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java @@ -27,16 +27,11 @@ import android.content.Context; import android.hardware.usb.*; import android.app.*; import android.os.Handler; -import android.util.Log; import org.altusmetrum.altoslib_7.*; public class AltosUsb extends AltosDroidLink { - // Debugging - private static final String TAG = "AltosUsb"; - private static final boolean D = true; - private Thread input_thread = null; private Handler handler; @@ -91,19 +86,19 @@ public class AltosUsb extends AltosDroidLink { } if (in != null && out != null) { - Log.d(TAG, String.format("\tin %s out %s\n", in.toString(), out.toString())); + AltosDebug.debug("\tin %s out %s\n", in.toString(), out.toString()); manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); if (manager == null) { - Log.d(TAG, "USB_SERVICE failed"); + AltosDebug.debug("USB_SERVICE failed"); return; } connection = manager.openDevice(device); if (connection == null) { - Log.d(TAG, "openDevice failed"); + AltosDebug.debug("openDevice failed"); return; } @@ -167,7 +162,7 @@ public class AltosUsb extends AltosDroidLink { // if (manager.hasPermission(device)) // return true; - Log.d(TAG, "request permission for USB device " + device.toString()); + AltosDebug.debug("request permission for USB device " + device.toString()); manager.requestPermission(device, pi); return false; @@ -183,7 +178,7 @@ public class AltosUsb extends AltosDroidLink { int product = device.getProductId(); if (matchProduct(match_product, device)) { - Log.d(TAG, "found USB device " + device.toString()); + AltosDebug.debug("found USB device " + device.toString()); return device; } } @@ -193,11 +188,11 @@ public class AltosUsb extends AltosDroidLink { private void disconnected() { if (closed()) { - if (D) Log.d(TAG, "disconnected after closed"); + AltosDebug.debug("disconnected after closed"); return; } - if (D) Log.d(TAG, "Sending disconnected message"); + AltosDebug.debug("Sending disconnected message"); handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); } @@ -210,20 +205,20 @@ public class AltosUsb extends AltosDroidLink { } if (tmp_connection != null) { - if (D) Log.d(TAG, "Closing USB device"); + AltosDebug.debug("Closing USB device"); tmp_connection.close(); } } int read(byte[] buffer, int len) { int ret = connection.bulkTransfer(in, buffer, len, -1); - if (D) Log.d(TAG, String.format("read(%d) = %d\n", len, ret)); + AltosDebug.debug("read(%d) = %d\n", len, ret); return ret; } int write(byte[] buffer, int len) { int ret = connection.bulkTransfer(out, buffer, len, -1); - if (D) Log.d(TAG, String.format("write(%d) = %d\n", len, ret)); + AltosDebug.debug("write(%d) = %d\n", len, ret); return ret; }