1
0
mirror of https://github.com/mik3y/usb-serial-for-android.git synced 2026-08-12 00:42:54 +00:00

Update demo activity.

Demo now consists of two activities:
  - DeviceListActivity shows all usb devices (including unsupported ones)
    in a ListView.
  - SerialConsoleActivity dumps the data stream for a device selected in
    DeviceListActivity.
This commit is contained in:
mike wakerly
2013-05-22 13:04:05 -07:00
parent b07bbcf292
commit b709823906
7 changed files with 372 additions and 55 deletions
@@ -107,6 +107,10 @@ public class HexDump {
return toHexString(toByteArray(i));
}
public static String toHexString(short i) {
return toHexString(toByteArray(i));
}
public static byte[] toByteArray(byte b) {
byte[] array = new byte[1];
array[0] = b;
@@ -124,6 +128,15 @@ public class HexDump {
return array;
}
public static byte[] toByteArray(short i) {
byte[] array = new byte[2];
array[1] = (byte) (i & 0xFF);
array[0] = (byte) ((i >> 8) & 0xFF);
return array;
}
private static int toByte(char c) {
if (c >= '0' && c <= '9')
return (c - '0');