Skip to content

Commit

Permalink
Version 1.16rc1
Browse files Browse the repository at this point in the history
Merged in chrishamm's changes to support tmie stamping of uploaded files
(thanks chrishamm)
Added fan mapping in M563 command
  • Loading branch information
dc42 committed Nov 3, 2016
1 parent f14c676 commit fcbf543
Show file tree
Hide file tree
Showing 49 changed files with 571 additions and 365 deletions.
8 changes: 6 additions & 2 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@
<option id="gnu.cpp.compiler.option.other.other.184134051" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -std=gnu++11 -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -nostdlib --param max-inline-insns-single=500" valueType="string"/>
<option id="gnu.cpp.compiler.option.include.paths.1285689288" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/cores/arduino}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Flash}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/RTCDue}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/SharedSpi}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Storage}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf/common/utils}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf/common/services/clock}&quot;"/>
Expand Down Expand Up @@ -196,9 +198,11 @@
<option id="gnu.cpp.compiler.option.other.other.549139443" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -std=gnu++11 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -nostdlib --param max-inline-insns-single=500" valueType="string"/>
<option id="gnu.cpp.compiler.option.include.paths.251815634" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/cores/arduino}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Flash}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/RTCDue}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/SharedSpi}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Storage}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf/common/utils}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${CoreName}/asf/common/services/clock}&quot;"/>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Release/Duet-0.6-0.8.5/RepRapFirmware-1.12-dc42.bin
Binary file not shown.
Binary file removed Release/Duet-0.6-0.8.5/RepRapFirmware-1.13a.bin
Binary file not shown.
Binary file removed Release/Duet-0.6-0.8.5/RepRapFirmware-1.15d.bin
Binary file not shown.
Binary file not shown.
Binary file removed Release/Duet-0.6-0.8.5/RepRapFirmware-1.16beta5.bin
Binary file not shown.
File renamed without changes.
Binary file removed Release/Duet-WiFi/DuetWiFiFirmware-1.15d.bin
Binary file not shown.
Binary file removed Release/Duet-WiFi/DuetWiFiFirmware-1.16beta10.bin
Binary file not shown.
Binary file removed Release/Duet-WiFi/DuetWiFiFirmware-1.16beta5.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added Release/Duet-WiFi/Stable/DuetWiFiServer-1.02.bin
Binary file not shown.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Licence: GPL
// Firmware name is now defined in the Pins file

#ifndef VERSION
# define VERSION "1.16beta10"
# define VERSION "1.16rc1"
#endif

#ifndef DATE
# define DATE "2016-10-28"
# define DATE "2016-11-03"
#endif

#define AUTHORS "reprappro, dc42, zpl, t3p3, dnewman"
Expand Down
4 changes: 2 additions & 2 deletions src/Duet/Pins_Duet.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const Pin COOLING_FAN_RPM_PIN = 23; // Pin PA15
const size_t NumSdCards = 2;
const Pin SdCardDetectPins[NumSdCards] = {13, NoPin};
const Pin SdWriteProtectPins[NumSdCards] = {NoPin, NoPin};
const Pin SdSpiCSPins[1] = {66}; // Note: this clashes with inkjet support
const Pin SdSpiCSPins[1] = {67}; // Note: this clashes with inkjet support

#if SUPPORT_INKJET
// Inkjet control pins
Expand All @@ -138,7 +138,7 @@ const Pin ROLAND_RTS_PIN = 17; // Expansion pin 12, PA13_RXD1
const Pin SpecialPinMap[] =
{
19, 18, 17, 16, 23, // PA10/RXD0 PA11/TXD0 PA12/RXD1 PA13/TXD1 PA14/RTS1
20, 21, 52, // PB12/TWD1 PB13/TWCK1 PB21/AD14
20, 21, 67, 52, // PB12/TWD1 PB13/TWCK1 PB16/DAC1 PB21/AD14
36 // PC4
};

Expand Down
57 changes: 48 additions & 9 deletions src/Duet/Webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
The supported requests are GET requests for files (for which the root is the www directory on the
SD card), and the following. These all start with "/rr_". Ordinary files used for the web interface
must not have names starting "/rr_" or they will not be found.
must not have names starting "/rr_" or they will not be found. Times should be generally specified
in the format YYYY-MM-DDTHH:MM:SS so the firmware can parse them.
rr_connect?password=xxx
rr_connect?password=xxx&time=yyy
Sent by the web interface software to establish an initial connection, indicating that
any state variables relating to the web interface (e.g. file upload in progress) should
be reset. This only happens if the password could be verified.
Expand Down Expand Up @@ -64,7 +65,7 @@
rr_download?name=xxx
Download a specified file from the SD card
rr_upload?name=xxx
rr_upload?name=xxx&time=yyy
Upload a specified file using a POST request. The payload of this request has to be
the file content. Only one file may be uploaded at once. When the upload has finished,
a JSON response with the variable "err" will be returned, which will be 0 if the job
Expand Down Expand Up @@ -681,8 +682,18 @@ void Webserver::HttpInterpreter::DoFastUpload()
}
}

// We're done, flush the remaining upload data and send the JSON response
// Grab a copy of the filename and finish this upload
char filename[FILENAME_LENGTH];
strncpy(filename, filenameBeingUploaded, FILENAME_LENGTH);
FinishUpload(postFileLength);

// Update the file timestamp if it was specified before
if (fileLastModified != 0)
{
(void)platform->GetMassStorage()->SetLastModifiedTime(filename, fileLastModified);
}

// Eventually send the JSON response
SendJsonResponse("upload");
}
else if (uploadState != uploadOK || !transaction->HasMoreDataToRead())
Expand Down Expand Up @@ -949,6 +960,17 @@ void Webserver::HttpInterpreter::GetJsonResponse(const char* request, OutputBuff
// Password OK
if (Authenticate())
{
// See if we can update the current RTC date and time
if (numQualKeys > 1 && StringEquals(qualifiers[1].key, "time") && !platform->IsDateTimeSet())
{
struct tm timeInfo;
if (strptime(qualifiers[1].value, "%Y-%m-%dT%H:%M:%S", &timeInfo) != nullptr)
{
time_t newTime = mktime(&timeInfo);
platform->SetDateTime(newTime);
}
}

// Client has been logged in
response->printf("{\"err\":0,\"sessionTimeout\":%u,\"boardType\":\"%s\"}", httpSessionTimeout, platform->GetBoardString());
}
Expand Down Expand Up @@ -1563,6 +1585,24 @@ bool Webserver::HttpInterpreter::ProcessMessage()
return RejectMessage("could not start file upload");
}

// Try to get the last modified file date and time
if (numQualKeys > 1 && StringEquals(qualifiers[1].key, "time"))
{
struct tm timeInfo;
if (strptime(qualifiers[1].value, "%Y-%m-%dT%H:%M:%S", &timeInfo) != nullptr)
{
fileLastModified = mktime(&timeInfo);
}
else
{
fileLastModified = 0;
}
}
else
{
fileLastModified = 0;
}

if (reprap.Debug(moduleWebserver))
{
platform->MessageF(HOST_MESSAGE, "Start uploading file %s length %lu\n", qualifiers[0].value, postFileLength);
Expand Down Expand Up @@ -2293,10 +2333,10 @@ void Webserver::FtpInterpreter::ProcessLine()
// Example for a typical UNIX-like file list:
// "drwxr-xr-x 2 ftp ftp 0 Apr 11 2013 bin\r\n"
const char dirChar = (fileInfo.isDirectory) ? 'd' : '-';
const uint8_t month = (fileInfo.month == 0) ? 1 : fileInfo.month; // without this check FileZilla won't display incomplete uploads properly
struct tm *timeInfo = localtime(&fileInfo.lastModified);
dataTransaction->Printf("%crw-rw-rw- 1 ftp ftp %13lu %s %02d %04d %s\r\n",
dirChar, fileInfo.size, platform->GetMassStorage()->GetMonthName(month),
fileInfo.day, fileInfo.year, fileInfo.fileName);
dirChar, fileInfo.size, platform->GetMassStorage()->GetMonthName(timeInfo->tm_mon + 1),
timeInfo->tm_mday, timeInfo->tm_year + 1900, fileInfo.fileName);
} while (platform->GetMassStorage()->FindNext(fileInfo));
}

Expand Down Expand Up @@ -2524,8 +2564,7 @@ void Webserver::FtpInterpreter::ChangeDirectory(const char *newDirectory)
//********************************************************************************************

Webserver::TelnetInterpreter::TelnetInterpreter(Platform *p, Webserver *ws, Network *n)
: ProtocolInterpreter(p, ws, n), connectedClients(0), processNextLine(false),
gcodeReadIndex(0), gcodeWriteIndex(0), gcodeReply(nullptr)
: ProtocolInterpreter(p, ws, n), connectedClients(0), processNextLine(false), gcodeReadIndex(0), gcodeWriteIndex(0), gcodeReply(nullptr)
{
ResetState();
}
Expand Down
7 changes: 4 additions & 3 deletions src/Duet/Webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,19 @@ class Webserver

char gcodeBuffer[gcodeBufferLength];
uint16_t gcodeReadIndex, gcodeWriteIndex; // head and tail indices into gcodeBuffer
uint32_t seq; // sequence number for G-Code replies

void LoadGcodeBuffer(const char* gc);
void ProcessGcode(const char* gc);
void StoreGcodeData(const char* data, uint16_t len);

// Responses from GCodes class

uint32_t seq; // Sequence number for G-Code replies
OutputStack *gcodeReply;

// File uploads
uint32_t postFileLength, uploadedBytes; // How many POST bytes do we expect and how many have already been written?
time_t fileLastModified;

// Deferred requests (rr_fileinfo)
ConnectionState * volatile deferredRequestConnection; // Which connection expects a response for a deferred request?
Expand Down Expand Up @@ -284,7 +285,7 @@ class Webserver
uint8_t connectedClients;

char clientMessage[ftpMessageLength];
unsigned int clientPointer;
size_t clientPointer;

char filename[FILENAME_LENGTH];
char currentDir[FILENAME_LENGTH];
Expand Down Expand Up @@ -336,7 +337,7 @@ class Webserver

bool processNextLine;
char clientMessage[GCODE_LENGTH];
uint16_t clientPointer;
size_t clientPointer;

bool ProcessLine();

Expand Down
48 changes: 35 additions & 13 deletions src/DuetNG/Webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
The supported requests are GET requests for files (for which the root is the www directory on the
SD card), and the following. These all start with "/rr_". Ordinary files used for the web interface
must not have names starting "/rr_" or they will not be found.
must not have names starting "/rr_" or they will not be found. Times should be generally specified
in the format YYYY-MM-DDTHH:MM:SS so the firmware can parse them.
rr_connect?password=xxx
rr_connect?password=xxx&time=yyy
Sent by the web interface software to establish an initial connection, indicating that
any state variables relating to the web interface (e.g. file upload in progress) should
be reset. This only happens if the password could be verified.
Expand Down Expand Up @@ -64,7 +65,7 @@
rr_download?name=xxx
Download a specified file from the SD card
rr_upload?name=xxx
rr_upload?name=xxx&time=yyy
Upload a specified file using a POST request. The payload of this request has to be
the file content. Only one file may be uploaded at once. When the upload has finished,
a JSON response with the variable "err" will be returned, which will be 0 if the job
Expand Down Expand Up @@ -180,7 +181,7 @@ void Webserver::Spin()
}

// This is called to process a file upload request.
void Webserver::StartUpload(HttpSession& session, const char* fileName, uint32_t fileLength)
void Webserver::StartUpload(HttpSession& session, const char* fileName, uint32_t fileLength, time_t lastModified)
{
CancelUpload(session);
if (uploadIp != 0)
Expand All @@ -197,6 +198,8 @@ void Webserver::StartUpload(HttpSession& session, const char* fileName, uint32_t
else
{
session.fileBeingUploaded.Set(file);
strncpy(session.filenameBeingUploaded, fileName, FILENAME_LENGTH);
session.fileLastModified = lastModified;
session.postLength = fileLength;
session.bytesWritten = 0;
session.nextFragment = 1;
Expand All @@ -223,6 +226,11 @@ void Webserver::FinishUpload(HttpSession& session)
{
session.uploadState = wrongLength;
}
else if (session.fileLastModified != 0)
{
// Upload OK, update the file timestamp if it was specified before
(void)platform->GetMassStorage()->SetLastModifiedTime(session.filenameBeingUploaded, session.fileLastModified);
}
}

if (session.uploadState != uploading)
Expand Down Expand Up @@ -450,9 +458,6 @@ void Webserver::HandleGCodeReply(const WebSource source, OutputBuffer *reply)
switch (source)
{
case WebSource::HTTP:
#if 0
OutputBuffer::ReleaseAll(reply);
#else
if (reply != nullptr)
{
if (numSessions > 0)
Expand All @@ -469,7 +474,6 @@ void Webserver::HandleGCodeReply(const WebSource source, OutputBuffer *reply)
OutputBuffer::ReleaseAll(reply);
}
}
#endif
break;

case WebSource::Telnet:
Expand All @@ -485,8 +489,6 @@ void Webserver::HandleGCodeReply(const WebSource source, const char *reply)
switch (source)
{
case WebSource::HTTP:
#if 0
#else
if (numSessions > 0)
{
OutputBuffer *buffer = gcodeReply->GetLastItem();
Expand All @@ -503,7 +505,6 @@ void Webserver::HandleGCodeReply(const WebSource source, const char *reply)
buffer->cat(reply);
seq++;
}
#endif
break;

case WebSource::Telnet:
Expand Down Expand Up @@ -538,7 +539,19 @@ bool Webserver::ProcessFirstFragment(HttpSession& session, const char* command,
{
if (session.isAuthenticated || reprap.CheckPassword(GetKeyValue("password")))
{
// Password OK
// Password is OK, see if we can update the current RTC date and time
const char *timeVal = GetKeyValue("time");
if (timeVal != nullptr && !platform->IsDateTimeSet())
{
struct tm timeInfo;
if (strptime(timeVal, "%Y-%m-%dT%H:%M:%S", &timeInfo) != nullptr)
{
time_t newTime = mktime(&timeInfo);
platform->SetDateTime(newTime);
}
}

// Client has logged in
session.isAuthenticated = true;
response->printf("{\"err\":0,\"sessionTimeout\":%u,\"boardType\":\"%s\"}", httpSessionTimeout, platform->GetBoardString());
}
Expand Down Expand Up @@ -604,11 +617,20 @@ bool Webserver::ProcessFirstFragment(HttpSession& session, const char* command,
{
const char* nameVal = GetKeyValue("name");
const char* lengthVal = GetKeyValue("length");
const char* timeVal = GetKeyValue("time");
if (nameVal != nullptr && lengthVal != nullptr)
{
// Try to obtain the last modified time
time_t fileLastModified = 0;
struct tm timeInfo;
if (timeVal != nullptr && strptime(timeVal, "%Y-%m-%dT%H:%M:%S", &timeInfo) != nullptr)
{
fileLastModified = mktime(&timeInfo);
}

// Deal with file upload request
uint32_t fileLength = atol(lengthVal);
StartUpload(session, nameVal, fileLength);
StartUpload(session, nameVal, fileLength, fileLastModified);
if (session.uploadState == uploading)
{
if (isOnlyFragment)
Expand Down
4 changes: 3 additions & 1 deletion src/DuetNG/Webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Webserver
uint32_t nextFragment;
uint32_t lastQueryTime;
FileData fileBeingUploaded;
char filenameBeingUploaded[FILENAME_LENGTH];
time_t fileLastModified;
uint32_t postLength;
uint32_t bytesWritten;
UploadState uploadState;
Expand All @@ -101,7 +103,7 @@ class Webserver
bool CharFromClient(char c, const char* &error);
bool ProcessFirstFragment(HttpSession& session, const char* command, bool isOnlyFragment);
void ProcessUploadFragment(HttpSession& session, const char* request, size_t length, uint32_t fragment);
void StartUpload(HttpSession& session, const char* fileName, uint32_t fileLength);
void StartUpload(HttpSession& session, const char* fileName, uint32_t fileLength, time_t lastModified);
void FinishUpload(HttpSession& session);
void CancelUpload(HttpSession& session);
bool GetJsonResponse(uint32_t remoteIp, const char* request, OutputBuffer *&response, const char* key, const char* value, size_t valueLength, bool& keepOpen);
Expand Down
Loading

0 comments on commit fcbf543

Please sign in to comment.