I keep having trouble using a previous preset.ini after a new upload. I have read the Save File Format docs. Whatever I try, most of the time it fails to read the old or edited preset.
I have defined KEEP_SAVEFILES_WHEN_PROGRAMMING
and made no changes in the number or type of presets in the config (I just want to keep the selected variations stored in preset.ini/tmp).
I have tried:
Using the old preset.ini/tmp without changes
Deleting the first 512 bytes of old preset.ini
(tried Notepad++ and a Hex editor)
Deleting the first 512 bytes and everything after END
Edit a preset via Edit Mode, so a new preset.ini/tmp is created, thereafter replacing the relevant text inside the new preset.ini/tmp without changing the fist 512 bytes (sometimes this seems to work, often it fails)
‘unlock_presets_ini.py’ program: I guess you have to put it in the same folder as preset.ini - when I click the program a window flashes and closes and nothing seems to have happened, I could not find any instructions (I have .py files associated with Python 3.7).
I moved this to a new topic.
Since you’re seeking help, not trying to help someone else, a new topic is generally better.
How do you know?
What do you use to determine if this was successful or not?
In general, you shouldn’t have to do anything if you have KEEP_SAVEFILES_WHEN_PROGRAMMING in your config file, it should just work.
Most of the steps you’ve tried are only relevant if you want to make any changes to your presets.ini file, although it doesn’t look like that’s what you wanted?
This is the right method if no changes are needed.
If that doesn’t work, that’s a bug and I should fix it.
This is the right method if you do want to make changes.
I don’t use windows much, but I think what you want to do is to drop the ini file onto the python program. If it works, the ini and tmp file will be renamed to *.bak and *.old, and a new ini file will be created which is much shorter and doesn’t have any of the checksum stuff.
Anyways, if this doesn’t help, I have more questions:
I was having the same trouble as well, but then found success when I used older preset.ini & preset.tmp files from a previous install - the ACTUAL files rather than copy/pasting the contents into the newly created ones (make sure your number of bladestyles is the same). It sounds like you may have tried that however?
Because the changes in the presets are not shown on the blade. I edit variation=n for each preset in preset.ini to select the preferred color, but only the variation=0 color appears on the blade. If I use the ProffieOS 7.8 color edit mode to change and save one preset, than that works, but all other presets are variation=0 now, so they are not taken over from the old preset.ini.
If I delete the first 512 bytes of preset.ini with Notepad++ or HxD the result is unpredictable.
Sometimes the preset.ini isn’t read at all. Sometimes all presets have disappeared except for the first one. Sometimes only the first preset disappears, when this happens the first preset can’t be selected on the saber and after using edit mode to change a color, the new preset.tmp indeed misses the first preset, I’ve attached the pastebin files:
Variation does not apply to Edit Mode styles, the colors are controlled by color arguments in OS6 & 7. This allows every effect color to be edited independently. Variation only applies to OS5 or earlier styles, perhaps this is why you’re not seeing changes?
If I run ‘unlock_presets_ini.py’ in Windows PowerShell I get the following error:
PS C:\_void\_presets> python unlock_presets_ini.py
Traceback (most recent call last):
File "unlock_presets_ini.py", line 87, in <module>
main()
File "unlock_presets_ini.py", line 78, in main
data = best.read()
File "unlock_presets_ini.py", line 55, in read
return self.f.read(self.length)
AttributeError: 'ProffieSafe' object has no attribute 'length'
Ok, so I’m not sure what happened to it, but the old preset.ini file is not a valid file, I see at least three things wrong with it:
It doesn’t pass checksum validation
The data starts oat byte 520, not 512 like it’s supposed to.
It has CRLF line endings, ProffieOS uses LF line endings.
I don’t know if it’s your editor or pastebin that messed it up though.
I don’t actually think it’s pastebin, because when I ran unlock_presets_ini.py on it, I got the same error that you got.
I updated unlock_presets_ini.py to provide better error messages when no valid file is found.
I’m not sure if this is also somehow related to the missing preset yet, just reporting what I’ve found so far.
Another result after using color change mode (here the the first preset was default at bootup, after using color change on this first preset the other 19 presets have disappeared): presets 19-missing.ini (254.0 KB)
There is still something weird going on with old presets.ini. It looks better, but the content checksum still doesn’t match. Also, it’s the wrong length, indicating that something or someone has tried to edit it by hand, which doesn’t work.
Removing the first 512 bytes should still work though.
However, there might be one caveat… You also need to remove the presets.tmp. If presets.ini is in the old format, but presets.tmp is in the new format (and valid) then the code will assume that presets.tmp is newer and prefer using that one. Is that possibly what is happening here?
One more caveat:
You really need to remove all the zeroes at the end of the file as well as the first 512 bytes. If the file is long enough, ProffieOS will assume that the file is in the new format and potentially fail to read it.
Just because they are there doesn’t mean that they are valid.
I added more error information to unlock_presets_init.py. It won’t do anything different, but it will tell you why it thinks the files are not valid.
It could be a bug in the program of course, or some difference in how python reads files on windows maybe?
Ok, I just tried that, the first time it was a succes.
The second time it failed with exactly the same preset file, but this time the saber startup up from another preset (last preset I used). If I reboot (pull the battery for a moment) to start from the first preset all is ok.
I’ve also tried this with SAVE_PRESET defined, I also got failures if I didn’t reboot.