projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/driver: Make HMC5883 driver build again
[fw/altos]
/
altosui
/
AltosDebug.java
diff --git
a/altosui/AltosDebug.java
b/altosui/AltosDebug.java
index 8d435b667d5ecb584b118bed27a5d9945b4abb92..c69369ef26a10683da2f6324642d6db1c6b09681 100644
(file)
--- a/
altosui/AltosDebug.java
+++ b/
altosui/AltosDebug.java
@@
-17,12
+17,8
@@
package altosui;
package altosui;
-import java.lang.*;
import java.io.*;
import java.io.*;
-import java.util.concurrent.*;
-import java.util.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosDebug extends AltosSerial {
public class AltosDebug extends AltosSerial {
@@
-62,7
+58,10
@@
public class AltosDebug extends AltosSerial {
void ensure_debug_mode() {
if (!debug_mode) {
printf("D\n");
void ensure_debug_mode() {
if (!debug_mode) {
printf("D\n");
- flush_input();
+ try {
+ flush_input();
+ } catch (InterruptedException ie) {
+ }
debug_mode = true;
}
}
debug_mode = true;
}
}
@@
-160,7
+159,11
@@
public class AltosDebug extends AltosSerial {
int i = 0;
byte[] data = new byte[length];
while (i < length) {
int i = 0;
byte[] data = new byte[length];
while (i < length) {
- String line = get_reply().trim();
+ String line = get_reply();
+
+ if (line == null)
+ throw new IOException("Timeout in read_bytes");
+ line = line.trim();
String tokens[] = line.split("\\s+");
for (int j = 0; j < tokens.length; j++) {
if (!Altos.ishex(tokens[j]) ||
String tokens[] = line.split("\\s+");
for (int j = 0; j < tokens.length; j++) {
if (!Altos.ishex(tokens[j]) ||
@@
-169,7
+172,12
@@
public class AltosDebug extends AltosSerial {
String.format
("Invalid read_bytes reply \"%s\"", line));
try {
String.format
("Invalid read_bytes reply \"%s\"", line));
try {
- data[i + j] = (byte) Integer.parseInt(tokens[j], 16);
+ if (i + j >= length)
+ throw new IOException(
+ String.format
+ ("Invalid read_bytes reply \"%s\"", line));
+ else
+ data[i + j] = (byte) Integer.parseInt(tokens[j], 16);
} catch (NumberFormatException ne) {
throw new IOException(
String.format
} catch (NumberFormatException ne) {
throw new IOException(
String.format