From b23e785bc7086094818c8d7d9daf9ffbd6589929 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Sun, 29 Apr 2018 13:26:49 +0100 Subject: Added Duet085 configuration (non-RTOS) --- src/BugList.txt | 2 +- src/Duet/MCP4461/MCP4461.cpp | 1 + src/Duet/MCP4461/MCP4461.h | 2 +- src/Duet/Network.cpp | 3 -- src/Duet/NetworkTransaction.cpp | 2 +- src/Duet/Pins_Duet.h | 3 +- src/Duet/Webserver.cpp | 61 +++++++++++++++++++++-------------------- src/Duet/Webserver.h | 2 +- src/Platform.cpp | 15 +++++++--- src/Version.h | 9 ++++-- 10 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/BugList.txt b/src/BugList.txt index 0640055f..880deb84 100644 --- a/src/BugList.txt +++ b/src/BugList.txt @@ -140,10 +140,10 @@ Todo in 1.21.1 bugfix release: - [believed fixed in 2.0b2] BUG movement system hangs sometimes if using very high microstepping, e.g. janke PSU model and config.g - [consider, done in 2.0] Simulation to assume machine starts homed, restore homed status at end - [consider, done in 2.0] Update user coordinates after using G10 to change offsets, https://www.duet3d.com/forum/thread.php?pid=44900#p44900 -- [done, test] Support M916 on older Duets Remaining: +- [done, test] Support M916 on older Duets - [done, test] M122 has some duplicate parts of network status on Maestro - [done, ok] prevent watchdog reset if MaxReps gets too high - [done] BUG manual probing, see https://github.com/dc42/RepRapFirmware/issues/170#issuecomment-380790290 diff --git a/src/Duet/MCP4461/MCP4461.cpp b/src/Duet/MCP4461/MCP4461.cpp index 1ce346c0..4a263cfa 100644 --- a/src/Duet/MCP4461/MCP4461.cpp +++ b/src/Duet/MCP4461/MCP4461.cpp @@ -1,4 +1,5 @@ #include "MCP4461.h" +#include "RepRapFirmware.h" /* Library to control the MCP4461 Digital Potentiometer over I2C. diff --git a/src/Duet/MCP4461/MCP4461.h b/src/Duet/MCP4461/MCP4461.h index 9d6ae941..d5ee32b6 100644 --- a/src/Duet/MCP4461/MCP4461.h +++ b/src/Duet/MCP4461/MCP4461.h @@ -6,7 +6,7 @@ #define DEFAULT_ADDRESS 0x2C //With A0 and A1 grounded #define DEFAULT_WIPER_VALUE 0x80 //Default to the wipers in midrange -// meory addresses (all shifted 4 bits left) +// memory addresses (all shifted 4 bits left) //For all the Wipers 0x100 = Full scale, 0x80 = mid scale, 0x0 = Zero scale #define MCP4461_VW0 0x00 #define MCP4461_VW1 0x10 diff --git a/src/Duet/Network.cpp b/src/Duet/Network.cpp index 3d2a8d3b..a0ddfaa5 100644 --- a/src/Duet/Network.cpp +++ b/src/Duet/Network.cpp @@ -422,7 +422,6 @@ void Network::Spin(bool full) UnlockLWIP(); platform.Message(UsbMessage, "Network down\n"); - platform.ClassReport(longWait); return; } @@ -457,7 +456,6 @@ void Network::Spin(bool full) UnlockLWIP(); platform.MessageF(UsbMessage, "Network up, IP=%s\n", IP4String(ip).c_str()); - platform.ClassReport(longWait); return; } } @@ -514,7 +512,6 @@ void Network::Spin(bool full) UnlockLWIP(); } - platform.ClassReport(longWait); webserver->Spin(); } diff --git a/src/Duet/NetworkTransaction.cpp b/src/Duet/NetworkTransaction.cpp index 2e64c139..b16e44b9 100644 --- a/src/Duet/NetworkTransaction.cpp +++ b/src/Duet/NetworkTransaction.cpp @@ -228,7 +228,7 @@ void NetworkTransaction::Write(OutputStack *stack) { if (CanWrite()) { - sendStack->Append(stack); + sendStack->Append(*stack); } else { diff --git a/src/Duet/Pins_Duet.h b/src/Duet/Pins_Duet.h index e4ec76b5..8f17abdf 100644 --- a/src/Duet/Pins_Duet.h +++ b/src/Duet/Pins_Duet.h @@ -117,8 +117,9 @@ constexpr Pin ATX_POWER_PIN = 12; // Arduino Due pin number that contr constexpr Pin Z_PROBE_PIN = 64; // aka A10 // Digital pin number to turn the IR LED on (high) or off (low) -constexpr Pin Z_PROBE_MOD_PIN06 = 52; // Digital pin number to turn the IR LED on (high) or off (low) on Duet v0.6 and v1.0 (PB21) +constexpr Pin Z_PROBE_MOD_PIN06 = 52; // Digital pin number to turn the IR LED on (high) or off (low) on Duet v0.6 and v1.0 (PB21) constexpr Pin Z_PROBE_MOD_PIN07 = X12; // Digital pin number to turn the IR LED on (high) or off (low) on Duet v0.7 and v0.8.5 (PC10) +constexpr Pin DiagPin = NoPin; // Pin number that the DAC that controls the second extruder motor current on the Duet 0.8.5 is connected to constexpr int Dac0DigitalPin = 66; // Arduino Due pin number corresponding to DAC0 output pin diff --git a/src/Duet/Webserver.cpp b/src/Duet/Webserver.cpp index 1756e324..e35bfc5d 100644 --- a/src/Duet/Webserver.cpp +++ b/src/Duet/Webserver.cpp @@ -127,14 +127,12 @@ void Webserver::Spin() // Check if we can actually send something back to the client if (OutputBuffer::GetBytesLeft(nullptr) == 0) { - platform->ClassReport(longWait); return; } // We must ensure that we have exclusive access to LWIP if (!network->Lock()) { - platform->ClassReport(longWait); return; } @@ -238,7 +236,6 @@ void Webserver::Spin() } network->Unlock(); // unlock LWIP again } - platform->ClassReport(longWait); } void Webserver::Exit() @@ -794,11 +791,9 @@ void Webserver::HttpInterpreter::SendJsonResponse(const char* command) if (StringEquals(command, "configfile")) // rr_configfile [DEPRECATED] { - const char *configPath = platform->GetMassStorage()->CombineName(platform->GetSysDir(), platform->GetConfigFile()); - char fileName[MaxFilenameLength]; - SafeStrncpy(fileName, configPath, MaxFilenameLength); - - SendFile(fileName, false); + String fileName; + MassStorage::CombineName(fileName.GetRef(), platform->GetSysDir(), platform->GetConfigFile()); + SendFile(fileName.c_str(), false); return; } @@ -939,7 +934,7 @@ void Webserver::HttpInterpreter::GetJsonResponse(const char* request, OutputBuff } else if (StringEquals(request, "gcode") && GetKeyValue("gcode") != nullptr) { - RegularGCodeInput * const httpInput = reprap.GetGCodes().GetHTTPInput(); + NetworkGCodeInput * const httpInput = reprap.GetGCodes().GetHTTPInput(); httpInput->Put(HttpMessage, GetKeyValue("gcode")); response->printf("{\"buff\":%u}", httpInput->BufferSpaceLeft()); } @@ -1721,7 +1716,7 @@ void Webserver::HttpInterpreter::ProcessDeferredRequest() // At the moment only file info requests are deferred. // Parsing the file may take a while, so keep LwIP running while we're waiting network->Unlock(); - bool gotFileInfo = reprap.GetPrintMonitor().GetFileInfoResponse(filenameBeingProcessed, jsonResponse); + bool gotFileInfo = reprap.GetFileInfoResponse(filenameBeingProcessed, jsonResponse, false); while (!network->Lock()); // Because LwIP was unlocked before, there is a chance that the ConnectionLost() call has already @@ -1993,7 +1988,7 @@ void Webserver::FtpInterpreter::ProcessLine() else if (StringStartsWith(clientMessage, "CWD")) { ReadFilename(3); - ChangeDirectory(filename); + ChangeDirectory(filename.c_str()); } // change to parent of current directory else if (StringEquals(clientMessage, "CDUP")) @@ -2048,7 +2043,7 @@ void Webserver::FtpInterpreter::ProcessLine() else if (StringStartsWith(clientMessage, "DELE")) { ReadFilename(4); - if (platform->GetMassStorage()->Delete(currentDir, filename)) + if (platform->GetMassStorage()->Delete(currentDir, filename.c_str())) { SendReply(250, "Delete operation successful."); } @@ -2061,7 +2056,7 @@ void Webserver::FtpInterpreter::ProcessLine() else if (StringStartsWith(clientMessage, "RMD")) { ReadFilename(3); - if (platform->GetMassStorage()->Delete(currentDir, filename)) + if (platform->GetMassStorage()->Delete(currentDir, filename.c_str())) { SendReply(250, "Remove directory operation successful."); } @@ -2074,11 +2069,17 @@ void Webserver::FtpInterpreter::ProcessLine() else if (StringStartsWith(clientMessage, "MKD")) { ReadFilename(3); - const char *location = (filename[0] == '/') - ? filename - : platform->GetMassStorage()->CombineName(currentDir, filename); + String location; + if (filename[0] == '/') + { + location.copy(filename.c_str()); + } + else + { + MassStorage::CombineName(location.GetRef(), currentDir, filename.c_str()); + } - if (platform->GetMassStorage()->MakeDirectory(location)) + if (platform->GetMassStorage()->MakeDirectory(location.c_str())) { NetworkTransaction *transaction = webserver->currentTransaction; transaction->Printf("257 \"%s\" created\r\n", location); @@ -2095,12 +2096,12 @@ void Webserver::FtpInterpreter::ProcessLine() ReadFilename(4); if (filename[0] != '/') { - const char *temp = platform->GetMassStorage()->CombineName(currentDir, filename); - SafeStrncpy(filename, temp, MaxFilenameLength); - filename[MaxFilenameLength - 1] = 0; + String temp; + MassStorage::CombineName(temp.GetRef(), currentDir, filename.c_str()); + filename.copy(temp.c_str()); } - if (platform->GetMassStorage()->FileExists(filename)) + if (platform->GetMassStorage()->FileExists(filename.c_str())) { SendReply(350, "Ready to RNTO."); } @@ -2112,13 +2113,13 @@ void Webserver::FtpInterpreter::ProcessLine() else if (StringStartsWith(clientMessage, "RNTO")) { // Copy origin path to temp oldFilename and read new path - char oldFilename[MaxFilenameLength]; - SafeStrncpy(oldFilename, filename, MaxFilenameLength); - oldFilename[MaxFilenameLength - 1] = 0; + String oldFilename; + oldFilename.copy(filename.c_str()); ReadFilename(4); - const char *newFilename = platform->GetMassStorage()->CombineName(currentDir, filename); - if (platform->GetMassStorage()->Rename(oldFilename, newFilename)) + String newFilename; + MassStorage::CombineName(newFilename.GetRef(), currentDir, filename.c_str()); + if (platform->GetMassStorage()->Rename(oldFilename.c_str(), newFilename.c_str())) { SendReply(250, "Rename successful."); } @@ -2223,8 +2224,8 @@ void Webserver::FtpInterpreter::ProcessLine() { ReadFilename(4); - FileStore *file = platform->OpenFile(currentDir, filename, OpenMode::write); - if (StartUpload(file, filename)) + FileStore *file = platform->OpenFile(currentDir, filename.c_str(), OpenMode::write); + if (StartUpload(file, filename.c_str())) { SendReply(150, "OK to send data."); state = doingPasvIO; @@ -2241,7 +2242,7 @@ void Webserver::FtpInterpreter::ProcessLine() { ReadFilename(4); - FileStore *file = platform->OpenFile(currentDir, filename, OpenMode::read); + FileStore *file = platform->OpenFile(currentDir, filename.c_str(), OpenMode::read); if (file == nullptr) { SendReply(550, "Failed to open file."); @@ -2642,7 +2643,7 @@ bool Webserver::TelnetInterpreter::ProcessLine() } // All other codes are stored for the GCodes class - RegularGCodeInput * const telnetInput = reprap.GetGCodes().GetTelnetInput(); + NetworkGCodeInput * const telnetInput = reprap.GetGCodes().GetTelnetInput(); telnetInput->Put(TelnetMessage, clientMessage); break; } diff --git a/src/Duet/Webserver.h b/src/Duet/Webserver.h index a7dee72b..c9c29108 100644 --- a/src/Duet/Webserver.h +++ b/src/Duet/Webserver.h @@ -273,7 +273,7 @@ protected: char clientMessage[ftpMessageLength]; size_t clientPointer; - char filename[MaxFilenameLength]; + String filename; char currentDir[MaxFilenameLength]; uint32_t portOpenTime; diff --git a/src/Platform.cpp b/src/Platform.cpp index 4542e1a9..312cbbd9 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -189,7 +189,10 @@ Platform::Platform() : // Initialise the Platform. Note: this is the first module to be initialised, so don't call other modules from here! void Platform::Init() { - pinMode(DiagPin, OUTPUT_LOW); // set up diag LED for debugging and turn it off + if (DiagPin != NoPin) + { + pinMode(DiagPin, OUTPUT_LOW); // set up diag LED for debugging and turn it off + } // Deal with power first pinMode(ATX_POWER_PIN, OUTPUT_LOW); @@ -1223,9 +1226,9 @@ bool Platform::FlushMessages() #ifdef SERIAL_AUX2_DEVICE // Write non-blocking data to the second AUX line - bool aux2hasMore; + bool aux2HasMore; { - MutexLocker lock(aux2MutexHandle); + MutexLocker lock(aux2Mutex); OutputBuffer *aux2OutputBuffer = aux2Output.GetFirstItem(); if (aux2OutputBuffer != nullptr) { @@ -1241,7 +1244,7 @@ bool Platform::FlushMessages() aux2Output.SetFirstItem(aux2OutputBuffer); } } - aux2hasMore = (aux2Output.GetFirstItem() != nullptr); + aux2HasMore = (aux2Output.GetFirstItem() != nullptr); } #endif @@ -1803,6 +1806,10 @@ void Platform::SoftwareReset(uint16_t reason, const uint32_t *stk) #endif } +#ifndef RSTC_MR_KEY_PASSWD +// Definition of RSTC_MR_KEY_PASSWD is missing in the SAM3X ASF files +# define RSTC_MR_KEY_PASSWD (0xA5u << 24) +#endif RSTC->RSTC_MR = RSTC_MR_KEY_PASSWD; // ignore any signal on the NRST pin for now so that the reset reason will show as Software Reset(); for(;;) {} diff --git a/src/Version.h b/src/Version.h index 22a64fb3..12cf9865 100644 --- a/src/Version.h +++ b/src/Version.h @@ -8,14 +8,17 @@ #ifndef SRC_VERSION_H_ #define SRC_VERSION_H_ + +#ifndef VERSION #ifdef RTOS -# define RTOSVER "(RTOS)" +# define RTOSVER "(RTOS)" +# define MAIN_VERSION "2.0" #else +# define MAIN_VERSION "1.21.1" # define RTOSVER #endif -#ifndef VERSION -# define VERSION "2.0" RTOSVER "beta3" +# define VERSION MAIN_VERSION RTOSVER "beta3" #endif #ifndef DATE -- cgit v1.2.3