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:
-rw-r--r--Maths/trilateration-l3.wxmxbin60204 -> 0 bytes
-rw-r--r--src/BugList.txt31
-rw-r--r--src/DuetNG/Pins_DuetNG.h6
-rw-r--r--src/Movement/Move.h13
-rw-r--r--src/Networking/FtpResponder.cpp54
-rw-r--r--src/Networking/FtpResponder.h8
-rw-r--r--src/Networking/HttpResponder.cpp5
-rw-r--r--src/Networking/HttpResponder.h6
-rw-r--r--src/Networking/NetworkResponder.cpp64
-rw-r--r--src/Networking/NetworkResponder.h11
-rw-r--r--src/Networking/UploadingNetworkResponder.cpp85
-rw-r--r--src/Networking/UploadingNetworkResponder.h32
-rw-r--r--src/Platform.cpp20
-rw-r--r--src/Platform.h1
-rw-r--r--src/Version.h6
15 files changed, 209 insertions, 133 deletions
diff --git a/Maths/trilateration-l3.wxmx b/Maths/trilateration-l3.wxmx
deleted file mode 100644
index b16bca05..00000000
--- a/Maths/trilateration-l3.wxmx
+++ /dev/null
Binary files differ
diff --git a/src/BugList.txt b/src/BugList.txt
index 44e72469..32edf1df 100644
--- a/src/BugList.txt
+++ b/src/BugList.txt
@@ -229,7 +229,7 @@ Done in 2.02 release:
- [done] Step clock on Duet Maestro going backwards, https://forum.duet3d.com/topic/8264/steptimer-getinterruptclocks-isn-t-incrementing
- [can't reproduce] Investigate Duet Maestro socket behaviour when cable disconnected, see email from chris
-2.03 planned:
+Done in 2.03beta1:
- [done, ok] MBytes/sec -> Mbytes/sec in M122 P104 report
- [done, ok] Remove 'RTOS' from firmware name?
- [done, ok] G1 X1E1 no longer gets treated as if it also has an E parameter
@@ -241,8 +241,18 @@ Done in 2.02 release:
- [done, ok with new filament monitor, test with old] Support filament sensor firmware v2
- [done, ok] Improve efficiency of debug print in WiFiInterface: don't keep calling cat and strlen
- [done, ok] Filament monitor to use time since end of last nonprinting extruder move
-- [done, ok on bench] Fix continuous rotation speed error bug on Polar kinematics, https://forum.duet3d.com/topic/8747/polar-printing-polar-axis-rotation-issue/3
+- [done, ok] Fix continuous rotation speed error bug on Polar kinematics, https://forum.duet3d.com/topic/8747/polar-printing-polar-axis-rotation-issue/3
- [done, ok, needs community test] Generalised Cartesian kinematics
+- [done, ok] fixed a crash in the crash handler when no task was active
+- [done, ok] Fix M3D Kanji problem on some displays
+- [done, ok] 4-tower delta kinematics
+- [done, ok] G2/G3 R parameter instead of IJ
+- [done, ok] On delta, G1 Y-100 after homing hits endstops - new limit check not working properly
+- [done, ok] Configurable 12864 SPI frequency
+- [done, ok] PR to send standby bed temperature in M408
+- [done, ok but test with babystepping] Deferred DM allocation and removal of DM array
+- [done] Support L parameter in M585, thanks chrishamm
+- [done] Scara R parameter to set min radius, https://github.com/dc42/RepRapFirmware/issues/221
- [done, test] Disable mdns in legacy Duets, https://forum.duet3d.com/topic/8352/duet-0-6-randomly-reboots/5
- [done, test] rr_fileinfo and M36 with no filename to include estimated print time and simulation time in the response, as in the report with a filename
- [done, test] In CNC and laser mode update user Z coordinate after tool change, https://forum.duet3d.com/topic/8181/tool-offset-honored-but-not-displayed-correctly
@@ -250,27 +260,22 @@ Done in 2.02 release:
- [done, test] G92 should not constrain the passed coordinates to the M208 limits if M564 S0 has been used to disable limits
- [done, test] Bug fix: month number written to height map.csv and filament files was too low by 1
- [done, test] wilriker PR to allow steps/mm to be quoted in M92, https://forum.duet3d.com/topic/8225/m92-parameter-to-indicate-microstepping/6
-- [done, ok but test with babystepping] Deferred DM allocation and removal of DM array
- [done, test] G30 S-3 option, to set trigger height to stopped height
- [done, test] Bug: 12864 display needs to be refreshed when a change in printer state alters visibility
- [done, test] When M106 Pn Sxxx received, if n = current print cooling fan number, update the print cooling fan speed variable, https://forum.duet3d.com/topic/8540/part-fan-value-missing/6
-- [done, test] PR to send standby bed temperature in M408
-- [done] Scara R parameter to set min radius, https://github.com/dc42/RepRapFirmware/issues/221
- [done, test] DAA to handle requested accel/decl > max
-- [done, ok] fixed a crash in the crash handler when no task was active
-- [done] Support L parameter in M585, thanks chrishamm
- [done, test] Suppress filenames starting with '.' in the 12864 display
- [done, test] Implement G17, error on G18/G19.
- [done, test] Core kinematics: enable all necessary motors
-- [done, ok] Fix M3D Kanji problem on some displays
-- [done, ok] 4-tower delta kinematics
- [done, test] Make G2/G3 segment length lower at low speeds, https://forum.duet3d.com/post/79040
- [done, test] Bug: M997 S1 sent from USB keeps returning M105 status reports while the wifi firmware is flashing, and PanelDue 'flashing' update messages get erased
- [done, test] M453 do the switch to CNC mode even if bad P parameter used
- [done, test] After pausing a print, if Cancel is pressed, cancel initial heating first like M108 does
-- [done, ok] G2/G3 R parameter instead of IJ
-- [done, ok] On delta, G1 Y-100 after homing hits endstops - new limit check not working properly
-- [done, ok] Configurable 12864 SPI frequency
+- [done, test] M122 P105 prints object sizes
+
+Planned for 2.03:
+- Test that M500 saves all delta rod lengths correctly
+- Test with Duet 3
- [could be related to visibility issue] Investigate 12864 display heater fault warning, https://forum.duet3d.com/topic/7718/12864-display-current-tool-temperatures/6
- Slow startup move issue, https://forum.duet3d.com/topic/8284/firmware-2-02-released/7 (adding S2 fixes it)
- M291 issue, https://forum.duet3d.com/topic/8381/m291-s2-does-not-block-macro-execution/5
@@ -284,11 +289,9 @@ Done in 2.02 release:
- Reports that DueX5 endstops stop working after a while, https://forum.duet3d.com/topic/8284/firmware-2-02-released/9
- I2C error recovery?
- Pressure advance issue? https://forum.duet3d.com/topic/8672/extruder-motors-skip-steps-with-pressure-advance-enabled/3
-- Test with Duet 3
- Command (M18/M84?) to enable specified motors or axes
- Add check for M208 min > max
- Don't keep sending "wifi reported error" messages during reconnection attempts, https://forum.duet3d.com/topic/8837/wifi-reported-error
-- test that M500 saves all delta rod lengths correctly
- M24 in filament-change.g macro doesn't resume the print
Investigations
diff --git a/src/DuetNG/Pins_DuetNG.h b/src/DuetNG/Pins_DuetNG.h
index 24299145..5531f6d6 100644
--- a/src/DuetNG/Pins_DuetNG.h
+++ b/src/DuetNG/Pins_DuetNG.h
@@ -10,9 +10,8 @@ constexpr size_t NumFirmwareUpdateModules = 4; // 3 modules, plus one for manua
// Features definition
#define HAS_LWIP_NETWORKING 0
-
-# define HAS_WIFI_NETWORKING 1
-# define HAS_W5500_NETWORKING 1
+#define HAS_WIFI_NETWORKING 1
+#define HAS_W5500_NETWORKING 1
#define HAS_CPU_TEMP_SENSOR 1
#define HAS_HIGH_SPEED_SD 1
@@ -29,6 +28,7 @@ constexpr size_t NumFirmwareUpdateModules = 4; // 3 modules, plus one for manua
#define SUPPORT_IOBITS 1 // set to support P parameter in G0/G1 commands
#define SUPPORT_DHT_SENSOR 1 // set nonzero to support DHT temperature/humidity sensors
#define SUPPORT_WORKPLACE_COORDINATES 1 // set nonzero to support G10 L2 and G53..59
+#define SUPPORT_12864_LCD 0 // set nonzero to support 12864 LCD and rotary encoder
#define SUPPORT_OBJECT_MODEL 1
#define SUPPORT_FTP 1
#define SUPPORT_TELNET 1
diff --git a/src/Movement/Move.h b/src/Movement/Move.h
index ed6be193..177a3a9d 100644
--- a/src/Movement/Move.h
+++ b/src/Movement/Move.h
@@ -18,19 +18,18 @@
// Define the number of DDAs and DMs.
// A DDA represents a move in the queue.
-// Each DDA needs one DM per drive that it moves.
-// However, DM's are large, so we provide fewer than DRIVES * DdaRingLength of them. The planner checks that enough DMs are available before filling in a new DDA.
+// Each DDA needs one DM per drive that it moves, but only when it has been prepared and frozen
#if SAME70
-const unsigned int DdaRingLength = 30;
-const unsigned int NumDms = DdaRingLength * 12; // allow enough for plenty of CAN expansion
+const unsigned int DdaRingLength = 40;
+const unsigned int NumDms = 20 * 12; // allow enough for plenty of CAN expansion
#elif SAM4E || SAM4S
-const unsigned int DdaRingLength = 30;
-const unsigned int NumDms = DdaRingLength * 8; // suitable for e.g. a delta + 5 input hot end
+const unsigned int DdaRingLength = 40;
+const unsigned int NumDms = 20 * 8; // suitable for e.g. a delta + 5 input hot end
#else
// We are more memory-constrained on the SAM3X
const unsigned int DdaRingLength = 20;
-const unsigned int NumDms = DdaRingLength * 5; // suitable for e.g. a delta + 2-input hot end
+const unsigned int NumDms = 20 * 5; // suitable for e.g. a delta + 2-input hot end
#endif
constexpr uint32_t MovementStartDelayClocks = StepTimer::StepClockRate/100; // 10ms delay between preparing the first move and starting it
diff --git a/src/Networking/FtpResponder.cpp b/src/Networking/FtpResponder.cpp
index 0375b627..1fc6dbb3 100644
--- a/src/Networking/FtpResponder.cpp
+++ b/src/Networking/FtpResponder.cpp
@@ -14,10 +14,9 @@
#include "NetworkInterface.h"
#include "Platform.h"
-FtpResponder::FtpResponder(NetworkResponder *n) : NetworkResponder(n), dataSocket(nullptr),
- passivePort(0), passivePortOpenTime(0), dataBuf(nullptr)
+FtpResponder::FtpResponder(NetworkResponder *n) : UploadingNetworkResponder(n), dataSocket(nullptr),
+ passivePort(0), passivePortOpenTime(0), dataBuf(nullptr), haveFileToMove(false)
{
- fileToMove.Clear();
}
// Ask the responder to accept this connection, returns true if it did
@@ -449,6 +448,9 @@ void FtpResponder::ProcessLine()
switch (responderState)
{
case ResponderState::authenticating:
+ haveFileToMove = false;
+ filenameBeingProcessed.Clear();
+
// don't check the user name
if (StringStartsWith(clientMessage, "USER"))
{
@@ -461,7 +463,7 @@ void FtpResponder::ProcessLine()
const char *password = GetParameter("PASS");
if (reprap.NoPasswordSet() || reprap.CheckPassword(password))
{
- strcpy(currentDirectory, "/");
+ currentDirectory.copy("/");
outBuf->copy("230 Login successful.\r\n");
Commit(ResponderState::reading);
@@ -505,7 +507,7 @@ void FtpResponder::ProcessLine()
// get current dir
else if (StringEqualsIgnoreCase(clientMessage, "PWD"))
{
- outBuf->printf("257 \"%s\"\r\n", currentDirectory);
+ outBuf->printf("257 \"%s\"\r\n", currentDirectory.c_str());
Commit(ResponderState::reading);
}
// set current dir
@@ -570,7 +572,7 @@ void FtpResponder::ProcessLine()
else if (StringStartsWith(clientMessage, "DELE"))
{
const char *filename = GetParameter("DELE");
- if (GetPlatform().GetMassStorage()->Delete(currentDirectory, filename))
+ if (GetPlatform().GetMassStorage()->Delete(currentDirectory.c_str(), filename))
{
outBuf->copy("250 Delete operation successful.\r\n");
}
@@ -584,7 +586,7 @@ void FtpResponder::ProcessLine()
else if (StringStartsWith(clientMessage, "RMD"))
{
const char *filename = GetParameter("RMD");
- if (GetPlatform().GetMassStorage()->Delete(currentDirectory, filename))
+ if (GetPlatform().GetMassStorage()->Delete(currentDirectory.c_str(), filename))
{
outBuf->copy("250 Remove directory operation successful.\r\n");
}
@@ -599,7 +601,7 @@ void FtpResponder::ProcessLine()
{
const char *filename = GetParameter("MKD");
String<MaxFilenameLength> location;
- MassStorage::CombineName(location.GetRef(), currentDirectory, filename);
+ MassStorage::CombineName(location.GetRef(), currentDirectory.c_str(), filename);
if (GetPlatform().GetMassStorage()->MakeDirectory(location.c_str()))
{
@@ -615,10 +617,11 @@ void FtpResponder::ProcessLine()
else if (StringStartsWith(clientMessage, "RNFR"))
{
const char *filename = GetParameter("RNFR");
- MassStorage::CombineName(fileToMove.GetRef(), currentDirectory, filename);
+ MassStorage::CombineName(filenameBeingProcessed.GetRef(), currentDirectory.c_str(), filename);
- if (GetPlatform().GetMassStorage()->FileExists(fileToMove.c_str()))
+ if (GetPlatform().GetMassStorage()->FileExists(filenameBeingProcessed.c_str()))
{
+ haveFileToMove = true;
outBuf->copy("350 Ready to RNTO.\r\n");
}
else
@@ -631,9 +634,9 @@ void FtpResponder::ProcessLine()
{
const char *filename = GetParameter("RNTO");
String<MaxFilenameLength> location;
- MassStorage::CombineName(location.GetRef(), currentDirectory, filename);
+ MassStorage::CombineName(location.GetRef(), currentDirectory.c_str(), filename);
- if (GetPlatform().GetMassStorage()->Rename(fileToMove.c_str(), location.c_str()))
+ if (haveFileToMove && GetPlatform().GetMassStorage()->Rename(filenameBeingProcessed.c_str(), location.c_str()))
{
outBuf->copy("250 Rename successful.\r\n");
}
@@ -641,6 +644,7 @@ void FtpResponder::ProcessLine()
{
outBuf->copy("500 Could not rename file or directory\r\n");
}
+ haveFileToMove = false;
Commit(ResponderState::reading);
}
// no op
@@ -652,6 +656,8 @@ void FtpResponder::ProcessLine()
// end connection
else if (StringEqualsIgnoreCase(clientMessage, "QUIT"))
{
+ haveFileToMove = false;
+ filenameBeingProcessed.Clear();
outBuf->copy("221 Goodbye.\r\n");
Commit();
}
@@ -674,7 +680,7 @@ void FtpResponder::ProcessLine()
// build directory listing, dataBuf is sent later in the Spin loop
MassStorage * const massStorage = GetPlatform().GetMassStorage();
FileInfo fileInfo;
- if (massStorage->FindFirst(currentDirectory, fileInfo))
+ if (massStorage->FindFirst(currentDirectory.c_str(), fileInfo))
{
do {
// Example for a typical UNIX-like file list:
@@ -708,8 +714,12 @@ void FtpResponder::ProcessLine()
// upload a file
else if (StringStartsWith(clientMessage, "STOR"))
{
- const char *filename = GetParameter("STOR");
- FileStore *file = GetPlatform().OpenFile(currentDirectory, filename, OpenMode::write);
+ // Variable filenameBeingProcessed is used for both uploading and for renaming files, so clear it here and clear haveFileToMove
+ haveFileToMove = false;
+ filenameBeingProcessed.Clear();
+
+ const char * const filename = GetParameter("STOR");
+ FileStore * const file = GetPlatform().OpenFile(currentDirectory.c_str(), filename, OpenMode::write);
if (file != nullptr)
{
StartUpload(file, filename);
@@ -726,8 +736,8 @@ void FtpResponder::ProcessLine()
// download a file
else if (StringStartsWith(clientMessage, "RETR"))
{
- const char *filename = GetParameter("RETR");
- fileBeingSent = GetPlatform().OpenFile(currentDirectory, filename, OpenMode::read);
+ const char * const filename = GetParameter("RETR");
+ fileBeingSent = GetPlatform().OpenFile(currentDirectory.c_str(), filename, OpenMode::read);
if (fileBeingSent != nullptr)
{
outBuf->printf("150 Opening data connection for %s (%lu bytes).\r\n", filename, fileBeingSent->Length());
@@ -817,12 +827,12 @@ void FtpResponder::ChangeDirectory(const char *newDirectory)
}
else if (StringEqualsIgnoreCase(newDirectory, "."))
{
- combinedPath.copy(currentDirectory);
+ combinedPath.copy(currentDirectory.c_str());
}
else if (StringEqualsIgnoreCase(newDirectory, "..")) // Go up
{
// Check if we're already at the root directory
- if (StringEqualsIgnoreCase(currentDirectory, "/"))
+ if (StringEqualsIgnoreCase(currentDirectory.c_str(), "/"))
{
outBuf->copy("550 Failed to change directory.\r\n");
Commit(responderState);
@@ -830,7 +840,7 @@ void FtpResponder::ChangeDirectory(const char *newDirectory)
}
// No - find the parent directory
- combinedPath.copy(currentDirectory);
+ combinedPath.copy(currentDirectory.c_str());
for(int i = combinedPath.strlen() - 2; i >= 0; i--)
{
if (combinedPath[i] == '/')
@@ -842,7 +852,7 @@ void FtpResponder::ChangeDirectory(const char *newDirectory)
}
else // Go to child directory
{
- combinedPath.copy(currentDirectory);
+ combinedPath.copy(currentDirectory.c_str());
if (!combinedPath.EndsWith('/') && combinedPath.strlen() > 1)
{
combinedPath.cat('/');
@@ -859,7 +869,7 @@ void FtpResponder::ChangeDirectory(const char *newDirectory)
// Verify the final path and change it if possible
if (GetPlatform().GetMassStorage()->DirectoryExists(combinedPath.GetRef()))
{
- SafeStrncpy(currentDirectory, combinedPath.c_str(), ARRAY_SIZE(currentDirectory));
+ currentDirectory.copy(combinedPath.c_str());
outBuf->copy("250 Directory successfully changed.\r\n");
Commit(responderState);
}
diff --git a/src/Networking/FtpResponder.h b/src/Networking/FtpResponder.h
index 3ba7b8a8..ee34f8fb 100644
--- a/src/Networking/FtpResponder.h
+++ b/src/Networking/FtpResponder.h
@@ -8,9 +8,9 @@
#ifndef SRC_NETWORKING_FTPRESPONDER_H_
#define SRC_NETWORKING_FTPRESPONDER_H_
-#include "NetworkResponder.h"
+#include "UploadingNetworkResponder.h"
-class FtpResponder : public NetworkResponder
+class FtpResponder : public UploadingNetworkResponder
{
public:
FtpResponder(NetworkResponder *n);
@@ -46,11 +46,11 @@ protected:
void CloseDataPort();
bool haveCompleteLine;
+ bool haveFileToMove;
char clientMessage[ftpMessageLength];
size_t clientPointer;
- char currentDirectory[MaxFilenameLength];
- String<MaxFilenameLength> fileToMove;
+ String<MaxFilenameLength> currentDirectory;
};
#endif /* SRC_NETWORKING_FTPRESPONDER_H_ */
diff --git a/src/Networking/HttpResponder.cpp b/src/Networking/HttpResponder.cpp
index cc443bd6..e5a275f5 100644
--- a/src/Networking/HttpResponder.cpp
+++ b/src/Networking/HttpResponder.cpp
@@ -32,7 +32,7 @@ const char* const ErrorPagePart2 =
"</p>\n"
"</body>\n";
-HttpResponder::HttpResponder(NetworkResponder *n) : NetworkResponder(n)
+HttpResponder::HttpResponder(NetworkResponder *n) : UploadingNetworkResponder(n)
{
}
@@ -647,6 +647,7 @@ bool HttpResponder::SendFileInfo(bool quitEarly)
}
else
{
+ filenameBeingProcessed.Clear();
Commit();
}
}
@@ -1319,7 +1320,7 @@ void HttpResponder::CancelUpload()
}
}
}
- NetworkResponder::CancelUpload();
+ UploadingNetworkResponder::CancelUpload();
}
// This overrides the version in class NetworkResponder
diff --git a/src/Networking/HttpResponder.h b/src/Networking/HttpResponder.h
index 02398f1d..addfd3a8 100644
--- a/src/Networking/HttpResponder.h
+++ b/src/Networking/HttpResponder.h
@@ -8,9 +8,9 @@
#ifndef SRC_NETWORKING_HTTPRESPONDER_H_
#define SRC_NETWORKING_HTTPRESPONDER_H_
-#include "NetworkResponder.h"
+#include "UploadingNetworkResponder.h"
-class HttpResponder : public NetworkResponder
+class HttpResponder : public UploadingNetworkResponder
{
public:
HttpResponder(NetworkResponder *n);
@@ -106,7 +106,7 @@ private:
// rr_fileinfo requests
uint32_t startedProcessingRequestAt; // when we started processing the current HTTP request
- String<MaxFilenameLength> filenameBeingProcessed; // The filename being processed (for rr_fileinfo)
+ // rr_fileinfo also uses fileBeingProcessed in the networkResponder class
// Keeping track of HTTP sessions
static HttpSession sessions[MaxHttpSessions];
diff --git a/src/Networking/NetworkResponder.cpp b/src/Networking/NetworkResponder.cpp
index 31061521..48a4c2d9 100644
--- a/src/Networking/NetworkResponder.cpp
+++ b/src/Networking/NetworkResponder.cpp
@@ -150,7 +150,6 @@ void NetworkResponder::SendData()
// This is called when we lose a connection or when we are asked to terminate. Overridden in some derived classes.
void NetworkResponder::ConnectionLost()
{
- CancelUpload();
OutputBuffer::ReleaseAll(outBuf);
outStack.ReleaseAll();
@@ -175,69 +174,6 @@ void NetworkResponder::ConnectionLost()
responderState = ResponderState::free;
}
-// Start writing to a new file
-void NetworkResponder::StartUpload(FileStore *file, const char *fileName)
-{
- fileBeingUploaded.Set(file);
- filenameBeingUploaded.copy(fileName);
- responderState = ResponderState::uploading;
- uploadError = false;
-}
-
-// If this responder has an upload in progress, cancel it
-void NetworkResponder::CancelUpload()
-{
- if (fileBeingUploaded.IsLive())
- {
- fileBeingUploaded.Close();
- if (!filenameBeingUploaded.IsEmpty())
- {
- GetPlatform().GetMassStorage()->Delete(FS_PREFIX, filenameBeingUploaded.c_str());
- }
- }
-}
-
-// Finish a file upload. Set variable uploadError if anything goes wrong.
-void NetworkResponder::FinishUpload(uint32_t fileLength, time_t fileLastModified)
-{
- // Flush remaining data for FSO
- if (!fileBeingUploaded.Flush())
- {
- uploadError = true;
- GetPlatform().Message(ErrorMessage, "Could not flush remaining data while finishing upload!\n");
- }
-
- // Check the file length is as expected
- if (fileLength != 0 && fileBeingUploaded.Length() != fileLength)
- {
- uploadError = true;
- GetPlatform().MessageF(ErrorMessage, "Uploaded file size is different (%lu vs. expected %lu bytes)!\n", fileBeingUploaded.Length(), fileLength);
- }
-
- // Close the file
- if (fileBeingUploaded.IsLive())
- {
- fileBeingUploaded.Close();
- }
-
- // Delete the file again if an error has occurred
- if (!filenameBeingUploaded.IsEmpty())
- {
- if (uploadError)
- {
- GetPlatform().GetMassStorage()->Delete(FS_PREFIX, filenameBeingUploaded.c_str());
- }
- else if (fileLastModified != 0)
- {
- // Update the file timestamp if it was specified
- (void)GetPlatform().GetMassStorage()->SetLastModifiedTime(nullptr, filenameBeingUploaded.c_str(), fileLastModified);
- }
- }
-
- // Clean up again
- filenameBeingUploaded.Clear();
-}
-
IPAddress NetworkResponder::GetRemoteIP() const
{
return (skt == nullptr) ? IPAddress() : skt->GetRemoteIP();
diff --git a/src/Networking/NetworkResponder.h b/src/Networking/NetworkResponder.h
index c4f379bc..8d7384fb 100644
--- a/src/Networking/NetworkResponder.h
+++ b/src/Networking/NetworkResponder.h
@@ -59,10 +59,6 @@ protected:
virtual void SendData();
virtual void ConnectionLost();
- void StartUpload(FileStore *file, const char *fileName);
- void FinishUpload(uint32_t fileLength, time_t fileLastModified);
- virtual void CancelUpload();
-
IPAddress GetRemoteIP() const;
void ReportOutputBufferExhaustion(const char *sourceFile, int line);
@@ -81,13 +77,6 @@ protected:
OutputStack outStack; // not volatile because only one task accesses it
FileStore *fileBeingSent;
NetworkBuffer *fileBuffer;
-
- // File uploads
- FileData fileBeingUploaded;
- String<MaxFilenameLength> filenameBeingUploaded;
- uint32_t postFileLength, uploadedBytes; // how many POST bytes do we expect and how many have already been written?
- time_t fileLastModified;
- bool uploadError;
};
#endif /* SRC_NETWORKING_NETWORKRESPONDER_H_ */
diff --git a/src/Networking/UploadingNetworkResponder.cpp b/src/Networking/UploadingNetworkResponder.cpp
new file mode 100644
index 00000000..204f2413
--- /dev/null
+++ b/src/Networking/UploadingNetworkResponder.cpp
@@ -0,0 +1,85 @@
+/*
+ * UploadingNetworkResponder.cpp
+ *
+ * Created on: 3 Feb 2019
+ * Author: David
+ */
+
+#include "UploadingNetworkResponder.h"
+#include "Socket.h"
+#include "Platform.h"
+
+UploadingNetworkResponder::UploadingNetworkResponder(NetworkResponder *n) : NetworkResponder(n), uploadError(false)
+{
+}
+
+// This is called when we lose a connection or when we are asked to terminate. Overridden in some derived classes.
+void UploadingNetworkResponder::ConnectionLost()
+{
+ CancelUpload();
+ NetworkResponder::ConnectionLost();
+}
+
+// Start writing to a new file
+void UploadingNetworkResponder::StartUpload(FileStore *file, const char *fileName)
+{
+ fileBeingUploaded.Set(file);
+ filenameBeingProcessed.copy(fileName);
+ responderState = ResponderState::uploading;
+ uploadError = false;
+}
+
+// If this responder has an upload in progress, cancel it
+void UploadingNetworkResponder::CancelUpload()
+{
+ if (fileBeingUploaded.IsLive())
+ {
+ fileBeingUploaded.Close();
+ if (!filenameBeingProcessed.IsEmpty())
+ {
+ GetPlatform().GetMassStorage()->Delete(nullptr, filenameBeingProcessed.c_str());
+ filenameBeingProcessed.Clear();
+ }
+ }
+}
+
+// Finish a file upload. Set variable uploadError if anything goes wrong.
+void UploadingNetworkResponder::FinishUpload(uint32_t fileLength, time_t fileLastModified)
+{
+ // Flush remaining data for FSO
+ if (!fileBeingUploaded.Flush())
+ {
+ uploadError = true;
+ GetPlatform().Message(ErrorMessage, "Could not flush remaining data while finishing upload!\n");
+ }
+
+ // Check the file length is as expected
+ if (fileLength != 0 && fileBeingUploaded.Length() != fileLength)
+ {
+ uploadError = true;
+ GetPlatform().MessageF(ErrorMessage, "Uploaded file size is different (%lu vs. expected %lu bytes)!\n", fileBeingUploaded.Length(), fileLength);
+ }
+
+ // Close the file
+ if (fileBeingUploaded.IsLive())
+ {
+ fileBeingUploaded.Close();
+ }
+
+ // Delete the file again if an error has occurred
+ if (!filenameBeingProcessed.IsEmpty())
+ {
+ if (uploadError)
+ {
+ GetPlatform().GetMassStorage()->Delete(nullptr, filenameBeingProcessed.c_str());
+ }
+ else if (fileLastModified != 0)
+ {
+ // Update the file timestamp if it was specified
+ (void)GetPlatform().GetMassStorage()->SetLastModifiedTime(nullptr, filenameBeingProcessed.c_str(), fileLastModified);
+ }
+ filenameBeingProcessed.Clear();
+ }
+}
+
+// End
diff --git a/src/Networking/UploadingNetworkResponder.h b/src/Networking/UploadingNetworkResponder.h
new file mode 100644
index 00000000..e94f7d3c
--- /dev/null
+++ b/src/Networking/UploadingNetworkResponder.h
@@ -0,0 +1,32 @@
+/*
+ * UploadingNetworkResponder.h
+ *
+ * Created on: 3 Feb 2019
+ * Author: David
+ */
+
+#ifndef SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_
+#define SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_
+
+#include "NetworkResponder.h"
+
+class UploadingNetworkResponder : public NetworkResponder
+{
+protected:
+ UploadingNetworkResponder(NetworkResponder *n);
+
+ void ConnectionLost() override;
+
+ void StartUpload(FileStore *file, const char *fileName);
+ void FinishUpload(uint32_t fileLength, time_t fileLastModified);
+ virtual void CancelUpload();
+
+ // File uploads
+ FileData fileBeingUploaded;
+ String<MaxFilenameLength> filenameBeingProcessed; // usually the name of the file being uploaded, but also used by HttpResponder and FtpResponder
+ uint32_t postFileLength, uploadedBytes; // how many POST bytes do we expect and how many have already been written?
+ time_t fileLastModified;
+ bool uploadError;
+};
+
+#endif /* SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_ */
diff --git a/src/Platform.cpp b/src/Platform.cpp
index 860a369d..d7a170d5 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -25,6 +25,7 @@
#include "Movement/DDA.h"
#include "Movement/Move.h"
#include "Movement/StepTimer.h"
+#include "Tools/Tool.h"
#include "Network.h"
#include "PrintMonitor.h"
#include "FilamentMonitors/FilamentMonitor.h"
@@ -63,6 +64,12 @@
# include "Display/Display.h"
#endif
+#if HAS_NETWORKING && !HAS_LEGACY_NETWORKING
+# include "Networking/HttpResponder.h"
+# include "Networking/FtpResponder.h"
+# include "Networking/TelnetResponder.h"
+#endif
+
#include <climits>
extern uint32_t _estack; // defined in the linker script
@@ -2597,6 +2604,19 @@ GCodeResult Platform::DiagnosticTest(GCodeBuffer& gb, const StringRef& reply, in
case (int)DiagnosticTestType::TimeSDWrite:
return reprap.GetGCodes().StartSDTiming(gb, reply);
+ case (int)DiagnosticTestType::PrintObjectSizes:
+ reply.printf(
+ "DDA %u, DM %u, Tool %u"
+#if HAS_NETWORKING && !HAS_LEGACY_NETWORKING
+ ", HTTP resp %u, FTP resp %u, Telnet resp %u"
+#endif
+ , sizeof(DDA), sizeof(DriveMovement), sizeof(Tool)
+#if HAS_NETWORKING && !HAS_LEGACY_NETWORKING
+ , sizeof(HttpResponder), sizeof(FtpResponder), sizeof(TelnetResponder)
+#endif
+ );
+ break;
+
#ifdef DUET_NG
case (int)DiagnosticTestType::PrintExpanderStatus:
reply.printf("Expander status %04X\n", DuetExpansion::DiagnosticRead());
diff --git a/src/Platform.h b/src/Platform.h
index 817c3cdc..8851a9c9 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -204,6 +204,7 @@ enum class DiagnosticTestType : int
TimeSquareRoot = 102, // do a timing test on the square root function
TimeSinCos = 103, // do a timing test on the trig functions
TimeSDWrite = 104, // do a write timing test on the SD card
+ PrintObjectSizes = 105, // print the sizes of various objects
TestWatchdog = 1001, // test that we get a watchdog reset if the tick interrupt stops
TestSpinLockup = 1002, // test that we get a software reset if a Spin() function takes too long
diff --git a/src/Version.h b/src/Version.h
index 4fc63698..e72f6bfb 100644
--- a/src/Version.h
+++ b/src/Version.h
@@ -11,16 +11,16 @@
#ifndef VERSION
#ifdef RTOS
-# define MAIN_VERSION "2.02+1"
+# define MAIN_VERSION "2.03beta1"
#else
-# define MAIN_VERSION "1.23+1"
+# define MAIN_VERSION "1.24beta1"
#endif
# define VERSION MAIN_VERSION
#endif
#ifndef DATE
-# define DATE "2019-02-03b1"
+# define DATE "2019-02-03b3"
#endif
#define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman, printm3d"