X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosUsb.java;h=8d0a725aef5347191e7da8868b89805d4d880c58;hp=81d50ab3b029b2b8dcf309cd2324a3e6f2c86894;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=7bfa8841b65707d629b425b306ec4cc3acfc156c diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java index 81d50ab3..8d0a725a 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,16 +28,11 @@ import android.content.Context; import android.hardware.usb.*; import android.app.*; import android.os.Handler; -import android.util.Log; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_11.*; 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 +87,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 +163,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 +179,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 +189,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 +206,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; }