@@ -104,9 +104,10 @@ public void close() throws SerialException {
104
104
105
105
public void hello () throws Exception {
106
106
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' ) {
109
109
throw new Exception ("Programmer not responding" );
110
+ }
110
111
String version = new String (answer );
111
112
if (!version .equals ("v10000" ))
112
113
throw new Exception ("Programmer version mismatch: " + version + ", but v10000 is required!" );
@@ -170,11 +171,15 @@ private boolean ack(int timeout) throws InterruptedException {
170
171
}
171
172
172
173
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 {
173
178
ByteArrayOutputStream out = new ByteArrayOutputStream ();
174
179
int written = 0 ;
175
180
while (timeout > 0 && written < expectedLen ) {
176
181
int c = read ();
177
- if (c != -1 ) {
182
+ if (c != -1 && (! asciionly || ( c > 0 && c < 128 )) ) {
178
183
out .write (c );
179
184
written ++;
180
185
continue ;
0 commit comments