Variable "already exists"
-
@fcwilt Oh, wow.
What I've been doing is editing config.g - just putting in a space, deleting it, then saving it, and telling it yes to restart the board. I just now did that to run another print, and I got a weird error message:
Error: Failed to rename file 0:/sys/config.g.part: file not found
And I couldn't see the Duet on the web interface. So I turned it off and on again (even pulled the plug) and when it comes on you hear the fans on rather loud (odd) and the web interface doesn't see it. The PanelDue does seem to work. Not sure what to do with this. I do have a backup of config.g on my PC.
-
@fcwilt I think maybe my SD card just died or something.
-
@donstauffer said in Variable "already exists":
@fcwilt I was thinking it might be "neater" just to do an if exists(var.Name). But if this is a bug, I wanted to report it. It doesn't seem like how you'd expect it to be intended.
I don't know if it is a bug or not - @dc42 would likely know or could find out.
As to testing for the existence, you know that the test will always be true for every print after the first whenever the printer powers up or is reset.
So, assuming it's not a bug, to my way of thinking it is cleaner to use globals.
Someone has asked for a way to "un-create" a variable which would also solve this sort of problem.
Frederick
-
@fcwilt Right now I'm concerned about that fact that all the files on the printer appear to be gone. I shut it off and popped the SD card out and pushed it back in, but still nothing. The printer comes on, and the BLTouch self-tests, and the fans go way up, and the PanelDue comes up. But I can't seem to do anything with it. No web interface, and config.g used to turn on my LED lights when you turned it on, but they're not coming on now. I wonder if connecting via USB might help.
-
@fcwilt Was able to connect via USB and an M20 shows my print files. So the SD card is still working. Must be that config.g is messed up. Not sure how to confirm that though.
-
@donstauffer said in Variable "already exists":
@fcwilt Right now I'm concerned about that fact that all the files on the printer appear to be gone. I shut it off and popped the SD card out and pushed it back in, but still nothing. The printer comes on, and the BLTouch self-tests, and the fans go way up, and the PanelDue comes up. But I can't seem to do anything with it. No web interface, and config.g used to turn on my LED lights when you turned it on, but they're not coming on now. I wonder if connecting via USB might help.
Can you connect the SD card to your computer and check the files that are on it?
Frederick
-
@fcwilt Good idea.
-
@fcwilt The files are there, including config.g, which shows zero bytes!
-
@fcwilt And config.g.bak with a date an hour earlier. Maybe I should rename config.g, then rename config.g.bak to config.g. Or copy it. Not sure which.
-
@donstauffer said in Variable "already exists":
@fcwilt And config.g.bak with a date an hour earlier. Maybe I should rename config.g, then rename config.g.bak to config.g. Or copy it. Not sure which.
I've seen that happen before.
The backup file should contain everything but the very last edits you made.
If config.g is empty then you can delete it (or rename it) and then rename the backup - all should be good except for the lost edits.
Frederick
-
@fcwilt First thing I just copied the entire SD card to my raid array. Then I renamed the files. Now I'll see what happens.
-
@fcwilt OK, that worked. And the last couple changes I made were to add and then delete a space to the file, so essentially, the backup has everything. Wow. That shouldn't have happened.
-
@fcwilt Anyhow, nice little bit of drama. Thanks for keeping me grounded there for a bit.
As to variables, I may just put in the test because it won't clutter the globals, and the whole purpose for them being in the file was that you could change them as needed. They function like constants in a normal language. So making them global would be counterproductive for this purpose.
But I wonder if this is by design. I doubt it.
-
@donstauffer said in Variable "already exists":
@fcwilt Anyhow, nice little bit of drama. Thanks for keeping me grounded there for a bit.
As to variables, I may just put in the test because it won't clutter the globals, and the whole purpose for them being in the file was that you could change them as needed. They function like constants in a normal language. So making them global would be counterproductive for this purpose.
But I wonder if this is by design. I doubt it.
If you are going to do the tests it might be easier to read if you had a section where you just tested and created the variables if needed and another section where you just set them knowing they either already exist OR they have just been created by the section above.
Otherwise you would have a bunch of if/else where the needed value appeared twice, once for the creation and once for the setting.
Frederick
-
@donstauffer said in Variable "already exists":
@fcwilt The files are there, including config.g, which shows zero bytes!
Interesting... I had this exact thing happen several weeks ago and am pretty sure it was due to a corrupted write. I had to delete config.g and renamed config.bak as config.g. The other way was to remove the SD drive and fix it in the PC - I always keep duplicates of the SD files on the PC for just this sort of reason.
-
@fcwilt I see what you mean. Create them with dummy values like zero, if they need to be created. That way the values only need to be tracked in one place. Not sure if you can create them without assigning a value. The documentation seems to say not.
-
@donstauffer said in Variable "already exists":
What I've been doing is editing config.g - just putting in a space, deleting it, then saving it, and telling it yes to restart the board.
Kind of a weird way to do it. Hitting the emergency stop button in DWC. Or sending M999 for a soft reset would be cleaner.
How often do you think you've done that to reset the board? I wonder if you've triggered a bug that fails to write the config.g.
-
@phaedrux Maybe a half dozen times a day. Usually I turn the machine off over night if I'm not printing anything long. I didn't know about M999 and I sort of thought emergency stop just kind of hung the machine and I had to turn it off anyway. Not sure. I haven't done it much.
-
The emergency stop button basically runs M112 to do a full halt, and then resets the firmware with M999.
https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M112_Emergency_Stop
https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M999_Restart
-
Was there anything unique to the time that it erased the config.g file?
For the sake of completeness, could you share the config.g and the results of M122?