Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCan Geliş <geliscan@gmail.com>2017-08-01 12:04:34 +0300
committerdc42 <dcrocker@eschertech.com>2017-08-01 12:04:34 +0300
commit3247390f323c07d5c834b206103397f295a95378 (patch)
tree1a0a2e81a6d59287a377450abf0917af04422bad /src/GCodes/GCodeInput.h
parent74890fbe742c1e4a96f862174260767d0b7daad2 (diff)
Support for binary write for M559 and M560 (#125)
* Support for binary write M560 and M559 now supports binary uploads. Size in bytes of the file can be supplied to the GCode with S parameter to indicate end of file otherwise upload will continue until the EOF is encountered. M560 writes www folder by default M559 writes sys folder by default Default folders can be changed by supplying the absolute path of the file. For example: M560 P/sys/firmware.bin * code refactoring * CRC32 checksum verification for binary uploads In this implementation CRC32 checksum should be supplied with "C" parameter with 0x prefix. Example: M559 C0xabcdef Ptest.bin S123 * code refactoring
Diffstat (limited to 'src/GCodes/GCodeInput.h')
-rw-r--r--src/GCodes/GCodeInput.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/GCodes/GCodeInput.h b/src/GCodes/GCodeInput.h
index 06c96fa2..4bd106d4 100644
--- a/src/GCodes/GCodeInput.h
+++ b/src/GCodes/GCodeInput.h
@@ -23,22 +23,23 @@ class GCodeInput
{
public:
virtual void Reset() = 0; // Clean all the cached data from this input
- virtual bool FillBuffer(GCodeBuffer *gb) = 0; // Fill a GCodeBuffer with the last available G-code
+ bool FillBuffer(GCodeBuffer *gb); // Fill a GCodeBuffer with the last available G-code
virtual size_t BytesCached() const = 0; // How many bytes have been cached?
+ 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.
// The only downside is that we cannot (yet) look through the hardware buffer and check for requested emergency stops.
// TODO: This will require some more work in the Arduino core.
-class StreamGCodeInput : GCodeInput
+class StreamGCodeInput : public GCodeInput
{
public:
StreamGCodeInput(Stream &dev) : device(dev) { }
void Reset() override;
- bool FillBuffer(GCodeBuffer *gb) override; // Fill a GCodeBuffer with the last available G-code
size_t BytesCached() const override; // How many bytes have been cached?
+ char ReadByte() override;
private:
Stream &device;
@@ -64,14 +65,14 @@ 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 : GCodeInput
+class RegularGCodeInput : public GCodeInput
{
public:
RegularGCodeInput(bool removeComments);
void Reset() override;
- bool FillBuffer(GCodeBuffer *gb) override; // Fill a GCodeBuffer with the last available G-code
size_t BytesCached() const override; // How many bytes have been cached?
+ char ReadByte() override;
void Put(MessageType mtype, const char c); // Append a single character
void Put(MessageType mtype, const char *buf); // Append a null-terminated string to the buffer