From: Mikko Rasa Date: Wed, 20 Nov 2013 20:23:37 +0000 (+0200) Subject: Avoid hogging the serial link with S88 read commands X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7ff47d1f59711542f4943aef02655d1bee51a8f6;p=r2c2.git Avoid hogging the serial link with S88 read commands --- diff --git a/source/libr2c2/arducontrol.cpp b/source/libr2c2/arducontrol.cpp index 2361d85..dd4e057 100644 --- a/source/libr2c2/arducontrol.cpp +++ b/source/libr2c2/arducontrol.cpp @@ -721,11 +721,17 @@ void ArduControl::RefreshTask::advance() ArduControl::S88Task::S88Task(ArduControl &c): control(c), n_octets(0), - octets_remaining(0) + octets_remaining(0), + delay(0) { } bool ArduControl::S88Task::get_work(PendingCommand &cmd) { + if(delay) + { + --delay; + return false; + } if(octets_remaining || !n_octets) return false; @@ -734,6 +740,8 @@ bool ArduControl::S88Task::get_work(PendingCommand &cmd) cmd.command[1] = octets_remaining; cmd.length = 2; + delay = 4; + return true; } diff --git a/source/libr2c2/arducontrol.h b/source/libr2c2/arducontrol.h index 1f45534..a8bdfa7 100644 --- a/source/libr2c2/arducontrol.h +++ b/source/libr2c2/arducontrol.h @@ -269,6 +269,7 @@ private: ArduControl &control; unsigned n_octets; unsigned octets_remaining; + unsigned delay; public: S88Task(ArduControl &);