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:
authorDavid Crocker <dcrocker@eschertech.com>2018-04-03 16:26:56 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-04-03 16:26:56 +0300
commit8f3f4431bc6db2405e82883323c64d80d07cdd87 (patch)
tree28666967f09d7a6756cb7d3feb85ce50b14030a4 /src/Storage
parent7e12acb1d004ea91373d2e90b9aaee584a19d98b (diff)
Network now a separate task
The Network module is now a separate task Reduced network buffers from 8 to 6 to free up RAM FileInfoParser has its own buffer to save allocating them on multiple stacks Got rid of longWait and ClassReport
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/FileInfoParser.cpp7
-rw-r--r--src/Storage/FileInfoParser.h9
2 files changed, 8 insertions, 8 deletions
diff --git a/src/Storage/FileInfoParser.cpp b/src/Storage/FileInfoParser.cpp
index 013caf1d..671095c4 100644
--- a/src/Storage/FileInfoParser.cpp
+++ b/src/Storage/FileInfoParser.cpp
@@ -106,7 +106,6 @@ bool FileInfoParser::GetFileInfo(const char *directory, const char *fileName, GC
const uint32_t loopStartTime = millis();
do
{
- uint32_t buf32[(GCODE_READ_SIZE + GCODE_OVERLAP_SIZE + 3)/4 + 1]; // buffer should be 32-bit aligned for HSMCI (need the +1 so we can add a null terminator)
char* const buf = reinterpret_cast<char*>(buf32);
size_t sizeToRead, sizeToScan; // number of bytes we want to read and scan in this go
@@ -120,7 +119,6 @@ bool FileInfoParser::GetFileInfo(const char *directory, const char *fileName, GC
sizeToRead = (size_t)min<FilePosition>(fileBeingParsed->Length() - fileBeingParsed->Position(), GCODE_READ_SIZE);
if (fileOverlapLength > 0)
{
- memcpy(buf, fileOverlap, fileOverlapLength);
sizeToScan = sizeToRead + fileOverlapLength;
}
else
@@ -195,7 +193,7 @@ bool FileInfoParser::GetFileInfo(const char *directory, const char *fileName, GC
{
// No - copy the last chunk of the buffer for overlapping search
fileOverlapLength = min<size_t>(sizeToRead, GCODE_OVERLAP_SIZE);
- memcpy(fileOverlap, &buf[sizeToRead - fileOverlapLength], fileOverlapLength);
+ memcpy(buf, &buf[sizeToRead - fileOverlapLength], fileOverlapLength);
}
}
break;
@@ -239,7 +237,7 @@ bool FileInfoParser::GetFileInfo(const char *directory, const char *fileName, GC
sizeToRead = (size_t)min<FilePosition>(fileBeingParsed->Length() - nextSeekPos, GCODE_READ_SIZE);
if (fileOverlapLength > 0)
{
- memcpy(&buf[sizeToRead], fileOverlap, fileOverlapLength);
+ memcpy(&buf[sizeToRead], buf, fileOverlapLength);
sizeToScan = sizeToRead + fileOverlapLength;
}
else
@@ -316,7 +314,6 @@ bool FileInfoParser::GetFileInfo(const char *directory, const char *fileName, GC
// Else go back further
fileOverlapLength = (size_t)min<FilePosition>(sizeToScan, GCODE_OVERLAP_SIZE);
- memcpy(fileOverlap, buf, fileOverlapLength);
nextSeekPos = (nextSeekPos <= GCODE_READ_SIZE) ? 0 : nextSeekPos - GCODE_READ_SIZE;
parseState = seeking;
}
diff --git a/src/Storage/FileInfoParser.h b/src/Storage/FileInfoParser.h
index 49f3572e..b9656dd6 100644
--- a/src/Storage/FileInfoParser.h
+++ b/src/Storage/FileInfoParser.h
@@ -20,7 +20,7 @@ const size_t GCODE_READ_SIZE = 2048; // How many bytes to read in one go in G
const size_t GCODE_READ_SIZE = 1024; // How many bytes to read in one go in GetFileInfo() (should be a multiple of 512 for read efficiency)
#endif
-const size_t GCODE_OVERLAP_SIZE = 100; // Size of the overlapping buffer for searching (should be a multiple of 4)
+const size_t GCODE_OVERLAP_SIZE = 100; // Size of the overlapping buffer for searching (must be a multiple of 4)
const uint32_t MAX_FILEINFO_PROCESS_TIME = 200; // Maximum time to spend polling for file info in each call
const uint32_t MaxFileParseInterval = 4000; // Maximum interval between repeat requests to parse a file
@@ -77,9 +77,12 @@ private:
GCodeFileInfo parsedFileInfo;
uint32_t lastFileParseTime;
uint32_t accumulatedParseTime, accumulatedReadTime, accumulatedSeekTime;
-
size_t fileOverlapLength;
- char fileOverlap[GCODE_OVERLAP_SIZE];
+
+ // We used to allocate the following buffer on the stack; but now that this is called by more than one task
+ // it is more economical to allocate it permanently because that lets us use smaller stacks.
+ // Alternatively, we could allocate a FileBuffer temporarily.
+ uint32_t buf32[(GCODE_READ_SIZE + GCODE_OVERLAP_SIZE + 3)/4 + 1]; // buffer must be 32-bit aligned for HSMCI. We need the +1 so we can add a null terminator.
};
#endif /* SRC_STORAGE_FILEINFOPARSER_H_ */