diff options
author | David Crocker <dcrocker@eschertech.com> | 2017-10-26 00:36:48 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2017-10-26 00:37:05 +0300 |
commit | ad73549a01954de291cea135cde2527d1883596e (patch) | |
tree | 0fcd0f7b05c9e40e986851c5f6455c0f1f589108 /src/Logger.cpp | |
parent | dff15aadac70efe87d3ec952af8b6a3d9acbcf66 (diff) |
Version 1.20beta2
New features:
On SCARA printera arm position limits are applied as well as XY size
limits
Heater 0 values are sent to to PanelDue even if there is no heated bed
When logging is enabled, log entries are now written for when the
date/time/date is set
When logging is enabled, "Maximum open file count exceeded" messages are
logged
Loss of power is now handled much faster. The print is paused in the
middle of a move if necessary. The M991 parameters are changed to
facilitate this.
When resuming a print after loss of power, the head is now moved,
sideways and finally down when restoring position
Following a power failure, M916 can now be used to resume the print
instead of using M98 Presurrect.g
The heater control now switches to fast PID parameters when the
temperature is within 3C of target, instead of within 1C
The TMC2660 Stallguard detection and Coolstep parameters may now be
configured using M915. Currently, no action os performed when a stall is
signalled.
If a heater fault occurs, the print is paused instead of cancelled
All error messages relating to incorrect use of a G- or M-code now
include the G- or M-number of the command that caused them
Increased ADC oversample bits to 2
Duet WiFi: M122 diagnostics now include the wifi module sleep mode and
additional network diagnostics
You can now disable monitorng of TMC2660 drivers rthat are not in use by
using parameter R-1 in the corresponding M569 command
The M585 (probe tool) command is now implemented (thanks chrrishamm)
If axis lengths are adjusted by probing, a subsequent M500 command saves
them in config-override.g
If tool offsets are adjusted by probing, a subsequent M500 command saves
them in config-override.g
The layer counting mechanism has been modified to better handle GCode
files that use a different layer height when printing support
Debug messages sent to the USB port are truncated or thrown away if a
software watchdog reset is imminent
XY speed limiting is now done separate for each kinematics, in
particular for CoreXY printers
Support for Polar kinematics has been added but not tested (see M669
command)
The TMC2660 drivers are configured to detect short-to-ground conditions
faster
The parameters in rr_ http commands are now all order-independent
Bug fixes
An error in computing the time taken to execute moves that were not yet
frozen caused the first movement on a SCARA printer following homing to
be jerky
An extra space in the output from the M114 command confused Printerface,
causing it to print exception messages
When tuning a heater, any previous maximum PWM that was set is now
ignored
Diffstat (limited to 'src/Logger.cpp')
-rw-r--r-- | src/Logger.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Logger.cpp b/src/Logger.cpp index e472f291..7d19237a 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -22,7 +22,7 @@ private: bool& b; }; -Logger::Logger() : logFile(), dirty(false), inLogger(false) +Logger::Logger() : logFile(), lastFlushTime(0), lastFlushFileSize(0), dirty(false), inLogger(false) { } @@ -35,7 +35,8 @@ void Logger::Start(time_t time, const StringRef& filename) if (f != nullptr) { logFile.Set(f); - logFile.Seek(logFile.Length()); + lastFlushFileSize = logFile.Length(); + logFile.Seek(lastFlushFileSize); InternalLogMessage(time, "Event logging started\n"); } } @@ -109,13 +110,26 @@ void Logger::InternalLogMessage(time_t time, const char *message) } } +// This is called regularly by Platform to give the logger an opportunity to flush the file buffer void Logger::Flush() { if (logFile.IsLive() && dirty && !inLogger) { - Lock loggerLock(inLogger); - logFile.Flush(); - dirty = false; + // Log file is dirty and can be flushed. + // To avoid excessive disk write operations, flush it only if one of the following is true: + // 1. We have possibly allocated a new cluster since the last flush. To avoid lost clusters if we power down before flushing, + // we should flush early in this case. Rather than determine the cluster size, we flush if we have started a new 512-byte sector. + // 2. If it hasn't been flushed for LogFlushInterval milliseconds. + const FilePosition currentPos = logFile.GetPosition(); + const uint32_t now = millis(); + if (now - lastFlushTime >= LogFlushInterval || currentPos/512 != lastFlushFileSize/512) + { + Lock loggerLock(inLogger); + logFile.Flush(); + lastFlushTime = millis(); + lastFlushFileSize = currentPos; + dirty = false; + } } } |