diff options
author | Christian Hammacher <bmasterc@gmail.com> | 2019-06-25 12:54:39 +0300 |
---|---|---|
committer | Christian Hammacher <bmasterc@gmail.com> | 2019-06-25 12:54:39 +0300 |
commit | 5b7f021cba21231c2099d268442cf0faea66e34c (patch) | |
tree | 4565159c0e520c73cbb1dbffdcfc266292b1aa76 /src/GCodes/GCodeInput.h | |
parent | 3825c7f2890cb07856925e3d7d489c36f1fee13c (diff) | |
parent | d8bf587c5fa3c6514bc4f3a3c17b4b5beb4e6110 (diff) |
Merge remote-tracking branch 'origin/v3-dev' into v3-chrishamm
Diffstat (limited to 'src/GCodes/GCodeInput.h')
-rw-r--r-- | src/GCodes/GCodeInput.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/GCodes/GCodeInput.h b/src/GCodes/GCodeInput.h index 7bc266e1..7faba438 100644 --- a/src/GCodes/GCodeInput.h +++ b/src/GCodes/GCodeInput.h @@ -16,21 +16,27 @@ const size_t GCodeInputBufferSize = 256; // How many bytes can we cache per input source? const size_t GCodeInputFileReadThreshold = 128; // How many free bytes must be available before data is read from the SD card? - -// This base class is intended to provide incoming G-codes for the GCodeBuffer class +// This base class provides incoming G-codes for the GCodeBuffer class class GCodeInput { public: virtual void Reset() = 0; // Clean all the cached data from this input - virtual bool FillBuffer(GCodeBuffer *gb); // Fill a GCodeBuffer with the last available G-code + virtual bool FillBuffer(GCodeBuffer *gb) = 0; // Fill a GCodeBuffer with the last available G-code virtual size_t BytesCached() const = 0; // How many bytes have been cached? +}; + +// This class provides a standard implementation of FillBuffer that calls ReadByte() to supply individual characters +class StandardGCodeInput : public GCodeInput +{ +public: + bool FillBuffer(GCodeBuffer *gb) override; // Fill a GCodeBuffer with the last available G-code protected: virtual char ReadByte() = 0; // Get the next byte from the source }; // This class wraps around an existing Stream device which lets us avoid double buffering. -class StreamGCodeInput : public GCodeInput +class StreamGCodeInput : public StandardGCodeInput { public: StreamGCodeInput(Stream &dev) : device(dev) { } @@ -64,7 +70,7 @@ enum class GCodeInputState // This class allows caching of dynamic content (from web-based sources) and implements a simple ring buffer. // In addition, incoming codes are checked for M112 (emergency stop) to execute perform emergency stops as quickly // as possible. Comments can be optionally stripped from sources where comments are not needed (e.g. HTTP). -class RegularGCodeInput : public GCodeInput +class RegularGCodeInput : public StandardGCodeInput { public: RegularGCodeInput(); |