summaryrefslogtreecommitdiff
path: root/altosui/Altos.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-07-05 21:41:44 -0700
committerKeith Packard <keithp@keithp.com>2011-07-05 21:41:44 -0700
commit4132ac5896114e5f3d8fb3f219422e8933078cf4 (patch)
treeb94126adde7a026467eee3bc91031d1ecbcf03c9 /altosui/Altos.java
parentef3ce687d73c1274ce5368432f4d449b063ce5c0 (diff)
altosui: Parse remaining standard telemetry packets
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/Altos.java')
-rw-r--r--altosui/Altos.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/altosui/Altos.java b/altosui/Altos.java
index 25d97bcf..37a4f67b 100644
--- a/altosui/Altos.java
+++ b/altosui/Altos.java
@@ -231,10 +231,21 @@ public class Altos {
static final Charset unicode_set = Charset.forName("UTF-8");
static String string(int[] bytes, int s, int l) {
- byte[] b = new byte[bytes.length];
+ if (s + l > bytes.length) {
+ if (s > bytes.length) {
+ s = bytes.length;
+ l = 0;
+ } else {
+ l = bytes.length - s;
+ }
+ }
+
+ byte[] b = new byte[l];
+
for (int i = 0; i < l; i++)
b[i] = (byte) bytes[s+i];
- return new String(b, unicode_set);
+ String n = new String(b, unicode_set);
+ return n;
}
static int hexbyte(String s, int i) {