From a6b151e7bda05aca49a88a09090026ef422d4c73 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 20 Dec 2018 14:13:11 -0800 Subject: [PATCH] Fix vision settings save --- .../rpiConfigServer_src/VisionSettings.cpp | 1 + .../rpiConfigServer_src/WebSocketHandlers.cpp | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/deps/tools/rpiConfigServer_src/VisionSettings.cpp b/deps/tools/rpiConfigServer_src/VisionSettings.cpp index 2fcf8dc..bcd96f1 100644 --- a/deps/tools/rpiConfigServer_src/VisionSettings.cpp +++ b/deps/tools/rpiConfigServer_src/VisionSettings.cpp @@ -30,6 +30,7 @@ void VisionSettings::Set(const wpi::json& data, return; } data.dump(os, 4); + os << '\n'; } // terminate vision process so it reloads the file diff --git a/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp b/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp index 09aa9b8..5d7c559 100644 --- a/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp +++ b/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp @@ -216,6 +216,13 @@ void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg) { << '\n'; return; } + } else if (subType == "Save") { + try { + VisionSettings::GetInstance()->Set(j.at("settings"), statusFunc); + } catch (const wpi::json::exception& e) { + wpi::errs() << "could not read visionSave value: " << e.what() << '\n'; + return; + } } } else if (t == "networkSave") { auto statusFunc = [s = ws.shared_from_this()](wpi::StringRef msg) { @@ -244,16 +251,6 @@ void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg) { wpi::errs() << "could not read networkSave value: " << e.what() << '\n'; return; } - } else if (t == "visionSave") { - auto statusFunc = [s = ws.shared_from_this()](wpi::StringRef msg) { - SendWsText(*s, {{"type", "status"}, {"message", msg}}); - }; - try { - VisionSettings::GetInstance()->Set(j.at("settings"), statusFunc); - } catch (const wpi::json::exception& e) { - wpi::errs() << "could not read visionSave value: " << e.what() << '\n'; - return; - } } }