From 10a75dc39bf4cd91d235861f11b1fa0365d75c3e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 3 Nov 2013 14:22:03 +0200 Subject: [PATCH] Make the programming utility recognize packetized replies --- arduprogram/main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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(); + } } -- 2.43.0