Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate displayconfig.json if erroneous #575

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tyeth
Copy link
Contributor

@tyeth tyeth commented Apr 22, 2024

It's possible for the display config file to be corrupt, at which point the funhouse fails to continue.
It's a standard file we generate so this commit regenerates the file if erroneous

@tyeth
Copy link
Contributor Author

tyeth commented Apr 22, 2024

Closes #563

@tyeth tyeth force-pushed the funhouse-display-config-recreate branch from d4017ab to 989f666 Compare April 22, 2024 15:32
@tyeth tyeth requested a review from brentru April 22, 2024 15:39
@tyeth
Copy link
Contributor Author

tyeth commented Apr 22, 2024

@brentru this one is also ready for review

@brentru
Copy link
Member

brentru commented Apr 22, 2024

@tyeth Can we hold on to this PR until we merge and release what's required for NO-OTA?

@tyeth
Copy link
Contributor Author

tyeth commented Apr 22, 2024 via email

@brentru
Copy link
Member

brentru commented Aug 9, 2024

@tyeth Should we look at this again?

@tyeth
Copy link
Contributor Author

tyeth commented Aug 9, 2024

Ah yes, also when secrets exists but is corrupt (usually 0bytes).

I've been seeing some weird behaviour regarding first boot after installation (second boot gives more stable filesystem), but not pinned down anything definitive.

@tyeth
Copy link
Contributor Author

tyeth commented Oct 15, 2024

Leaving this one open until file system corruption issue is resolved hopefully this week. It could go in as is, but there will be movement in same code areas as we try to avoid unnecessary file writes at boot.

@tyeth
Copy link
Contributor Author

tyeth commented Nov 15, 2024

Note to add this when I do #655

@tyeth tyeth force-pushed the funhouse-display-config-recreate branch from db2af9c to b7a915a Compare November 22, 2024 14:42
@brentru
Copy link
Member

brentru commented Feb 11, 2025

@tyeth Do we still want this?

@brentru
Copy link
Member

brentru commented Mar 3, 2025

@tyeth Should I take another look at this, this week?

@tyeth
Copy link
Contributor Author

tyeth commented Mar 7, 2025

Yes please

Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyeth I am requesting some changes but the overall idea looks good.

@@ -529,7 +529,16 @@ void Wippersnapper_FS::createDisplayConfig() {
delay(2500); // give FS some time to write the file
}

void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
bool Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg, bool forceRecreate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change forceRecreate to force_recreateand give it a default param here:bool force_recreate=false`

@@ -59,7 +59,7 @@ class Wippersnapper_FS {
void parseSecrets();

#ifdef ARDUINO_FUNHOUSE_ESP32S2
void parseDisplayConfig(displayConfig &displayFile);
bool parseDisplayConfig(displayConfig &displayFile, bool forceRecreate = false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not set default arg in header, set in .cpp

@@ -542,13 +551,19 @@ void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
// Attempt to open file for JSON parsing
File32 file = wipperFatFs.open("/display_config.json", FILE_READ);
if (!file) {
if (!forceRecreate && parseDisplayConfig(dispCfg, true)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call to parseDisplayConfig() within parseDisplayConfig() potentially causes recursion.

Instead, I'd like to see this segment (and the segment on L564, which has the same logic) returning false and whatever calls this should check the return and then attempt to call parseDisplayConfig(dispCfg, true).

fsHalt("FATAL ERROR: Unable to open display_config.json for parsing");
}

// Attempt to deserialize the file's json document
JsonDocument doc;
DeserializationError error = deserializeJson(doc, file);
if (error) {
if (!forceRecreate && parseDisplayConfig(dispCfg, true)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment about L554, this is the same potential recursion issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants