From: Mikko Rasa Date: Sun, 3 Nov 2013 12:22:03 +0000 (+0200) Subject: Make the programming utility recognize packetized replies X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=10a75dc39bf4cd91d235861f11b1fa0365d75c3e;p=model-railway-devices.git Make the programming utility recognize packetized replies --- diff --git a/arduprogram/main.cpp b/arduprogram/main.cpp index e9f62ca..a6b989f 100644 --- a/arduprogram/main.cpp +++ b/arduprogram/main.cpp @@ -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(); + } }