Skip to content

Commit

Permalink
Merge branch '3.5-dev' of https://github.com/Duet3D/RepRapFirmware.git
Browse files Browse the repository at this point in the history
…into 3.5-dev
  • Loading branch information
dc42 committed Sep 17, 2024
2 parents 647584b + d56654b commit ae71104
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: Upload prerelease assets

on:
release:
types: [prereleased]
types:
- published

jobs:
build:
if: "github.event.release.prerelease"
runs-on: ubuntu-22.04
steps:
# Download release assets
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: Upload release assets

on:
release:
types: [released]
types:
- published

jobs:
build:
if: "!github.event.release.prerelease"
runs-on: ubuntu-22.04
steps:
# Download release assets
Expand Down
3 changes: 2 additions & 1 deletion src/CAN/CommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,11 @@ void CommandProcessor::ProcessReceivedMessage(CanMessageBuffer *buf) noexcept
if (buf->id.Src() != CanInterface::GetCanAddress()) // I don't think we should receive our own broadcasts, but in case we do...
{
if ( buf->id.Dst() != CanId::BroadcastAddress
&& buf->id.MsgType() != CanMessageType::fanTachoReport // don't flash whenever we receive a regular status message
&& buf->id.MsgType() != CanMessageType::fansReport // don't flash whenever we receive a regular status message
&& buf->id.MsgType() != CanMessageType::heatersStatusReport
&& buf->id.MsgType() != CanMessageType::boardStatusReport
&& buf->id.MsgType() != CanMessageType::driversStatusReport
&& buf->id.MsgType() != CanMessageType::filamentMonitorsStatusReportNew
)
{
reprap.GetPlatform().OnProcessingCanMessage();
Expand Down
15 changes: 14 additions & 1 deletion src/GCodes/GCodeBuffer/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

BinaryParser::BinaryParser(GCodeBuffer& gcodeBuffer) noexcept : gb(gcodeBuffer)
{
header = reinterpret_cast<const CodeHeader *>(gcodeBuffer.buffer);
header = reinterpret_cast<CodeHeader *>(gcodeBuffer.buffer);
}

void BinaryParser::Init() noexcept
Expand Down Expand Up @@ -600,6 +600,19 @@ FilePosition BinaryParser::GetFilePosition() const noexcept
return ((header->flags & CodeFlags::HasFilePosition) != 0) ? header->filePosition : noFilePosition;
}

void BinaryParser::SetFilePosition(FilePosition fpos) noexcept
{
if (fpos == noFilePosition)
{
header->flags = (CodeFlags)(header->flags & ~CodeFlags::HasFilePosition);
}
else
{
header->filePosition = fpos;
header->flags = (CodeFlags)(header->flags | CodeFlags::HasFilePosition);
}
}

const char* BinaryParser::DataStart() const noexcept
{
return gb.buffer;
Expand Down
3 changes: 2 additions & 1 deletion src/GCodes/GCodeBuffer/BinaryParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BinaryParser
void SetFinished() noexcept; // Set the G Code finished

FilePosition GetFilePosition() const noexcept; // Get the file position at the start of the current command
void SetFilePosition(FilePosition fpos) noexcept; // Overwrite the file position, e.g. when a macro finishes

const char* DataStart() const noexcept; // Get the start of the current command
size_t DataLength() const noexcept; // Get the length of the current command
Expand All @@ -78,7 +79,7 @@ class BinaryParser
void WriteParameters(const StringRef& s, bool quoteStrings) const noexcept;

size_t bufferLength;
const CodeHeader *header;
CodeHeader *header;

int reducedBytesRead;
ParameterLettersBitmap parametersPresent;
Expand Down
22 changes: 13 additions & 9 deletions src/GCodes/GCodeBuffer/GCodeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void GCodeBuffer::Reset() noexcept
isBinaryBuffer = false;
requestedMacroFile.Clear();
isWaitingForMacro = macroFileClosed = false;
macroJustStarted = macroJustFinished = macroFileError = macroFileEmpty = abortFile = abortAllFiles = sendToSbc = messagePromptPending = messageAcknowledged = false;
macroJustStarted = macroFileError = macroFileEmpty = abortFile = abortAllFiles = sendToSbc = messagePromptPending = messageAcknowledged = false;
machineState->lastCodeFromSbc = machineState->macroStartedByCode = false;
#endif
cancelWait = false;
Expand Down Expand Up @@ -298,7 +298,7 @@ void GCodeBuffer::PutBinary(const uint32_t *data, size_t len) noexcept
{
machineState->lastCodeFromSbc = true;
isBinaryBuffer = true;
macroJustStarted = macroJustFinished = false;
macroJustStarted = false;
binaryParser.Put(data, len);
}

Expand Down Expand Up @@ -1187,8 +1187,15 @@ void GCodeBuffer::MacroFileClosed() noexcept
{
machineState->CloseFile();
macroJustStarted = false;
macroJustFinished = macroFileClosed = true;
macroFileClosed = true;
#if HAS_SBC_INTERFACE
if (IsBinary())
{
// File position of the last code is no longer valid when we get here, reset it
binaryParser.SetFilePosition(IsFileChannel() && OriginalMachineState().DoingFile() ? printFilePositionAtMacroStart : noFilePosition);
}
reprap.GetSbcInterface().EventOccurred();
#endif
}

#endif
Expand Down Expand Up @@ -1251,12 +1258,9 @@ FilePosition GCodeBuffer::GetPrintingFilePosition(bool allowNoFilePos) const noe
}

#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_SBC_INTERFACE
const FilePosition pos = (IsDoingFileMacro()
# if HAS_SBC_INTERFACE
|| IsMacroFileClosed() || macroJustFinished // wait for the next code from the SBC to update the job file position
# endif
) ? printFilePositionAtMacroStart // the position before we started executing the macro
: GetJobFilePosition(); // the actual position, allowing for bytes cached but not yet processed
const FilePosition pos = IsDoingFileMacro()
? printFilePositionAtMacroStart // the position before we started executing the macro
: GetJobFilePosition(); // the actual position
return (pos != noFilePosition || allowNoFilePos) ? pos : 0;
#else
return allowNoFilePos ? noFilePosition : 0;
Expand Down
5 changes: 2 additions & 3 deletions src/GCodes/GCodeBuffer/GCodeBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,8 @@ class GCodeBuffer INHERIT_OBJECT_MODEL
// Accessed only when the GB mutex is acquired
String<MaxFilenameLength> requestedMacroFile;
bool isBinaryBuffer;
uint16_t
uint8_t
macroJustStarted : 1, // Whether the GB has just started a macro file
macroJustFinished : 1, // Whether the GB has just finished a macro file
macroFileError : 1, // Whether the macro file could be opened or if an error occurred
macroFileEmpty : 1, // Whether the macro file is actually empty
abortFile : 1, // Whether to abort the last file on the stack
Expand All @@ -391,7 +390,7 @@ class GCodeBuffer INHERIT_OBJECT_MODEL
inline bool GCodeBuffer::IsDoingFileMacro() const noexcept
{
#if HAS_SBC_INTERFACE
return machineState->doingFileMacro || IsMacroRequestPending();
return machineState->doingFileMacro || IsMacroRequestPending() || macroFileClosed;
#else
return machineState->doingFileMacro;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/GCodes/GCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ bool GCodes::DoAsynchronousPause(GCodeBuffer& gb, PrintPausedReason reason, GCod
// TODO: when using RTOS there is a possible race condition in the following,
// because we might try to pause when a waiting move has just been added but before the gcode buffer has been re-initialised ready for the next command
ms.GetPauseRestorePoint().filePos = fgb.GetPrintingFilePosition(true);
while (fgb.IsDoingFileMacro()) // must call this after GetFilePosition because this changes IsDoingFileMacro
while (fgb.LatestMachineState().doingFileMacro) // must call this after GetFilePosition because this changes IsDoingFileMacro
{
ms.pausedInMacro = true;
fgb.PopState(false);
Expand Down
8 changes: 7 additions & 1 deletion src/GCodes/GCodes2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ bool GCodes::HandleGcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
}

GCodeResult result = GCodeResult::ok;
if (IsSimulating() && code > 4 && code != 10 && code != 11 && code != 20 && code != 21 && (code < 53 || code > 59) && (code < 90 || code > 94))
if (IsSimulating() && code > 4 // move & dwell
&& code != 10 && code != 11 // (un)retract
&& code != 17 && code != 18 && code != 19 // selected plane for arc moves
&& code != 68 && code != 69 // coordinate rotation
&& code != 20 && code != 21 // change units
&& (code < 53 || code > 59) // coordinate system
&& (code < 90 || code > 94)) // positioning & feedrate modes
{
HandleReply(gb, result, "");
return true; // we only simulate some gcodes
Expand Down
2 changes: 1 addition & 1 deletion src/GCodes/GCodes3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ GCodeResult GCodes::DoDriveMapping(GCodeBuffer& gb, const StringRef& reply) THRO
const AxisWrapType wrapType = (newAxesType != AxisWrapType::undefined) ? newAxesType
: (c >= 'A' && c <= 'D') ? AxisWrapType::wrapAt360 // default A thru D to rotational but not continuous
: AxisWrapType::noWrap; // default other axes to linear
const bool isNistRotational = (seenS) ? newAxesAreNistRotational : (c >= 'A' && c <= 'D');
const bool isNistRotational = (seenS) ? newAxesAreNistRotational : wrapType != AxisWrapType::noWrap;
platform.SetAxisType(drive, wrapType, isNistRotational);
++numTotalAxes;
if (numTotalAxes + numExtruders > MaxAxesPlusExtruders)
Expand Down
6 changes: 6 additions & 0 deletions src/ObjectModel/ObjectModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,10 @@ void ObjectModel::ReportItemAsJsonFull(OutputBuffer *buf, ObjectExplorationConte
{
buf->cat('[');
}

context.AddIndex(index);
ReportItemAsJson(buf, context, classDescriptor, element, endptr + 1);
context.RemoveIndex();

if (*filter == 0)
{
Expand Down Expand Up @@ -1130,7 +1133,10 @@ void ObjectModel::ReportHeapArrayAsJson(OutputBuffer *buf, ObjectExplorationCont
}
ExpressionValue element;
ah.GetElement(i, element);

context.AddIndex(i);
ReportItemAsJson(buf, context, classDescriptor, element, filter);
context.RemoveIndex();
}
if (isRootArray && context.GetNextElement() < 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5326,7 +5326,7 @@ GCodeResult Platform::EutProcessM569Point7(const CanMessageGeneric& msg, const S
parser.GetStringParam('C', portName.GetRef());
//TODO use the following instead when we track the enable state of each driver individually
//if (!brakePorts[drive].AssignPort(portName.c_str(), reply, PinUsedBy::gpout, (driverDisabled[drive]) ? PinAccess::write0 : PinAccess::write1)) ...
if (brakePorts[drive].AssignPort(portName.c_str(), reply, PinUsedBy::gpout, PinAccess::write0))
if (!brakePorts[drive].AssignPort(portName.c_str(), reply, PinUsedBy::gpout, PinAccess::write0))
{
return GCodeResult::error;
}
Expand Down

0 comments on commit ae71104

Please sign in to comment.