MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / RequestMacroFile

Method RequestMacroFile

src/GCodes/GCodeBuffer/GCodeBuffer.cpp:1175–1210  ·  view source on GitHub ↗

This is only called when using the SBC interface and returns if the macro file could be opened

Source from the content-addressed store, hash-verified

1173
1174// This is only called when using the SBC interface and returns if the macro file could be opened
1175bool GCodeBuffer::RequestMacroFile(const char *filename, bool fromCode) noexcept
1176{
1177 if (!reprap.GetSbcInterface().IsConnected())
1178 {
1179 // Don't wait for a macro file if no SBC is connected
1180 return false;
1181 }
1182
1183 // Request the macro file from the SBC
1184 macroJustStarted = macroFileError = macroFileEmpty = false;
1185 machineState->macroStartedByCode = fromCode;
1186 requestedMacroFile.copy(filename);
1187
1188 // There is no need to block the main task if daemon.g is requested.
1189 // If it doesn't exist, DSF will simply close the virtual file again
1190 if (GetChannel() != GCodeChannel::Daemon || machineState->doingFileMacro)
1191 {
1192 // Wait for a response (but not forever)
1193 isWaitingForMacro = true;
1194 reprap.GetSbcInterface().EventOccurred(true);
1195 if (!macroSemaphore.Take(SpiMaxRequestTime))
1196 {
1197 isWaitingForMacro = false;
1198 reprap.GetPlatform().MessageF(ErrorMessage, "Timeout while waiting for macro file %s (channel %s)\n", filename, GetChannel().ToString());
1199 return false;
1200 }
1201 }
1202
1203 // When we get here we expect the SBC interface to have set the variables above for us
1204 if (!macroFileError)
1205 {
1206 macroJustStarted = true;
1207 return true;
1208 }
1209 return false;
1210}
1211
1212void GCodeBuffer::ResolveMacroRequest(bool hadError, bool isEmpty) noexcept
1213{

Callers 1

DoFileMacroMethod · 0.80

Calls 4

copyMethod · 0.80
EventOccurredMethod · 0.80
TakeMethod · 0.80
MessageFMethod · 0.45

Tested by

no test coverage detected