Skip to content
This repository was archived by the owner on Jul 9, 2020. It is now read-only.

Commit a0b421e

Browse files
committed
Fixed filament functions for usage with SBC
1 parent 198cb95 commit a0b421e

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

src/GCodes/GCodes.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ void GCodes::DoFilePrint(GCodeBuffer& gb, const StringRef& reply)
566566
HandleReply(gb, GCodeResult::ok, "");
567567
}
568568
}
569+
else if (gb.GetState() == GCodeState::loadingFilament && hadFileError)
570+
{
571+
// Don't perform final filament assignment if the load macro could not be processed
572+
gb.SetState(GCodeState::normal);
573+
HandleReply(gb, GCodeResult::ok, "");
574+
}
569575
else if (gb.GetState() == GCodeState::normal)
570576
{
571577
UnlockAll(gb);
@@ -3505,14 +3511,6 @@ GCodeResult GCodes::LoadFilament(GCodeBuffer& gb, const StringRef& reply)
35053511
return GCodeResult::error;
35063512
}
35073513

3508-
#if HAS_MASS_STORAGE
3509-
if (!platform.DirectoryExists(FILAMENTS_DIRECTORY, filamentName.c_str()))
3510-
{
3511-
reply.copy("Filament configuration directory not found");
3512-
return GCodeResult::error;
3513-
}
3514-
#endif
3515-
35163514
if (Filament::IsInUse(filamentName.c_str()))
35173515
{
35183516
reply.copy("One filament type can be only assigned to a single tool");

src/GCodes/GCodes2.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,10 +3997,11 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply)
39973997
case 703: // Configure Filament
39983998
if (reprap.GetCurrentTool() != nullptr)
39993999
{
4000-
if (reprap.GetCurrentTool()->GetFilament() != nullptr)
4000+
const Filament *filament = reprap.GetCurrentTool()->GetFilament();
4001+
if (filament != nullptr && filament->IsLoaded())
40014002
{
40024003
String<ScratchStringLength> scratchString;
4003-
scratchString.printf("%s%s/%s", FILAMENTS_DIRECTORY, reprap.GetCurrentTool()->GetFilament()->GetName(), CONFIG_FILAMENT_G);
4004+
scratchString.printf("%s%s/%s", FILAMENTS_DIRECTORY, filament->GetName(), CONFIG_FILAMENT_G);
40044005
DoFileMacro(gb, scratchString.c_str(), false, 703);
40054006
}
40064007
}

src/Linux/LinuxInterface.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,14 @@ void LinuxInterface::Spin()
294294
Filament *filament = Filament::GetFilamentByExtruder(extruder);
295295
if (filament != nullptr)
296296
{
297-
filament->Load(filamentName.c_str());
297+
if (filamentName.IsEmpty())
298+
{
299+
filament->Unload();
300+
}
301+
else
302+
{
303+
filament->Load(filamentName.c_str());
304+
}
298305
}
299306
break;
300307
}

src/Tools/Filament.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ void Filament::Unload() noexcept
4242
void Filament::LoadAssignment() noexcept
4343
{
4444
#if HAS_MASS_STORAGE
45+
# if HAS_LINUX_INTERFACE
46+
if (reprap.UsingLinuxInterface())
47+
{
48+
// Filament configuration is saved on the SBC
49+
return;
50+
}
51+
# endif
52+
4553
FileStore *file = reprap.GetPlatform().OpenSysFile(FilamentAssignmentFile, OpenMode::read);
4654
if (file == nullptr)
4755
{
@@ -81,6 +89,14 @@ void Filament::LoadAssignment() noexcept
8189
/*static*/ void Filament::SaveAssignments() noexcept
8290
{
8391
#if HAS_MASS_STORAGE
92+
# if HAS_LINUX_INTERFACE
93+
if (reprap.UsingLinuxInterface())
94+
{
95+
// Filament configuration is saved on the SBC
96+
return;
97+
}
98+
# endif
99+
84100
FileStore * const file = reprap.GetPlatform().OpenSysFile(FilamentAssignmentFile, OpenMode::write);
85101
if (file == nullptr)
86102
{

0 commit comments

Comments
 (0)