projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosui, telegps, altosdroid: say ground distance, not total range
[fw/altos]
/
altosdroid
/
src
/
org
/
altusmetrum
/
AltosDroid
/
AltosUsb.java
diff --git
a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java
b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java
index 4685a82470cae609161714d66d53f053ea5a56f4..8d0a725aef5347191e7da8868b89805d4d880c58 100644
(file)
--- 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
*
* 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
*
* 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.hardware.usb.*;
import android.app.*;
import android.os.Handler;
-import android.util.Log;
-import org.altusmetrum.altoslib_
7
.*;
+import org.altusmetrum.altoslib_
11
.*;
public class AltosUsb extends AltosDroidLink {
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;
private Thread input_thread = null;
private Handler handler;
@@
-91,19
+87,19
@@
public class AltosUsb extends AltosDroidLink {
}
if (in != null && out != null) {
}
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) {
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) {
return;
}
connection = manager.openDevice(device);
if (connection == null) {
-
Log.d(TAG,
"openDevice failed");
+
AltosDebug.debug(
"openDevice failed");
return;
}
return;
}
@@
-167,7
+163,7
@@
public class AltosUsb extends AltosDroidLink {
// if (manager.hasPermission(device))
// return true;
// 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;
manager.requestPermission(device, pi);
return false;
@@
-183,7
+179,7
@@
public class AltosUsb extends AltosDroidLink {
int product = device.getProductId();
if (matchProduct(match_product, device)) {
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;
}
}
return device;
}
}
@@
-193,11
+189,11
@@
public class AltosUsb extends AltosDroidLink {
private void disconnected() {
if (closed()) {
private void disconnected() {
if (closed()) {
-
if (D) Log.d(TAG,
"disconnected after closed");
+
AltosDebug.debug(
"disconnected after closed");
return;
}
return;
}
-
if (D) Log.d(TAG,
"Sending disconnected message");
+
AltosDebug.debug(
"Sending disconnected message");
handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget();
}
handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget();
}
@@
-210,20
+206,20
@@
public class AltosUsb extends AltosDroidLink {
}
if (tmp_connection != null) {
}
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);
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);
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;
}
return ret;
}