]> git.tdb.fi Git - model-railway-devices.git/commitdiff
Make the programming utility recognize packetized replies
authorMikko Rasa <tdb@tdb.fi>
Sun, 3 Nov 2013 12:22:03 +0000 (14:22 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 3 Nov 2013 12:22:03 +0000 (14:22 +0200)
arduprogram/main.cpp

index e9f62ca2dfb8e6c8c18d79079c69003e0326cfd9..a6b989fa64a0839812655cf15f4c21afd762ee49 100644 (file)
@@ -271,9 +271,15 @@ void ArduProgram::set_output_state(OutputState s)
 
 void ArduProgram::serial_input_available()
 {
-       int c = serial.get();
-       if(c==0x80)
-               set_output();
-       else
-               throw runtime_error(format("Command error: %x\n", c));
+       unsigned l = serial.get()^0xFF;
+       if(l<0x10)
+       {
+               int c = serial.get();
+               if(c==0x80)
+                       set_output();
+               else if((c&0xE0)==0x80)
+                       throw runtime_error(format("Command error: %x\n", c));
+               while(--l)
+                       serial.get();
+       }
 }