Skip to content

Commit 7188569

Browse files
committed
Add an asciiolny version of waitAnswer
1 parent a6eac0b commit 7188569

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/cc/arduino/plugins/wifi101/flashers/java/FlasherSerialClient.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ public void close() throws SerialException {
104104

105105
public void hello() throws Exception {
106106
sendCommand((byte) 0x99, 0x11223344, 0x55667788, null);
107-
byte[] answer = waitAnswer(100, 6);
108-
if (answer.length != 6 || answer[0] != 'v')
107+
byte[] answer = waitAnswer(2000, 6, true);
108+
if (answer.length != 6 || answer[0] != 'v') {
109109
throw new Exception("Programmer not responding");
110+
}
110111
String version = new String(answer);
111112
if (!version.equals("v10000"))
112113
throw new Exception("Programmer version mismatch: " + version + ", but v10000 is required!");
@@ -170,11 +171,15 @@ private boolean ack(int timeout) throws InterruptedException {
170171
}
171172

172173
private byte[] waitAnswer(int timeout, int expectedLen) throws InterruptedException {
174+
return waitAnswer(timeout, expectedLen, false);
175+
}
176+
177+
private byte[] waitAnswer(int timeout, int expectedLen, boolean asciionly) throws InterruptedException {
173178
ByteArrayOutputStream out = new ByteArrayOutputStream();
174179
int written = 0;
175180
while (timeout > 0 && written < expectedLen) {
176181
int c = read();
177-
if (c != -1) {
182+
if (c != -1 && (!asciionly || (c > 0 && c < 128))) {
178183
out.write(c);
179184
written++;
180185
continue;

0 commit comments

Comments
 (0)