This is only called when using the SBC interface and returns if the macro file could be opened
| 1173 | |
| 1174 | // This is only called when using the SBC interface and returns if the macro file could be opened |
| 1175 | bool 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 | |
| 1212 | void GCodeBuffer::ResolveMacroRequest(bool hadError, bool isEmpty) noexcept |
| 1213 | { |
no test coverage detected