George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 1 | #include "lamptest.hpp" |
| 2 | |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 3 | #include <phosphor-logging/lg2.hpp> |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 4 | |
George Liu | c5e0f31 | 2021-12-27 15:54:31 +0800 | [diff] [blame] | 5 | #include <algorithm> |
| 6 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 7 | namespace phosphor |
| 8 | { |
| 9 | namespace led |
| 10 | { |
| 11 | |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 12 | using Json = nlohmann::json; |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 13 | static const fs::path lampTestIndicator = |
| 14 | "/var/lib/phosphor-led-manager/lamp-test-running"; |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 15 | |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 16 | bool LampTest::processLEDUpdates(const ActionSet& ledsAssert, |
| 17 | const ActionSet& ledsDeAssert) |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 18 | { |
| 19 | // If the physical LED status is updated during the lamp test, it should be |
| 20 | // saved to Queue, and the queue will be processed after the lamp test is |
| 21 | // stopped. |
| 22 | if (isLampTestRunning) |
| 23 | { |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 24 | // Physical LEDs will be updated during lamp test |
| 25 | for (const auto& it : ledsDeAssert) |
| 26 | { |
George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame] | 27 | std::string path = std::string(phyLedPath) + it.name; |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 28 | auto iter = std::find_if( |
| 29 | forceUpdateLEDs.begin(), forceUpdateLEDs.end(), |
| 30 | [&path](const auto& name) { return name == path; }); |
| 31 | |
| 32 | if (iter != forceUpdateLEDs.end()) |
| 33 | { |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 34 | phosphor::led::Manager::drivePhysicalLED( |
| 35 | path, Layout::Action::Off, it.dutyOn, it.period); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
| 39 | for (const auto& it : ledsAssert) |
| 40 | { |
George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame] | 41 | std::string path = std::string(phyLedPath) + it.name; |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 42 | auto iter = std::find_if( |
| 43 | forceUpdateLEDs.begin(), forceUpdateLEDs.end(), |
| 44 | [&path](const auto& name) { return name == path; }); |
| 45 | |
| 46 | if (iter != forceUpdateLEDs.end()) |
| 47 | { |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 48 | phosphor::led::Manager::drivePhysicalLED(path, it.action, |
| 49 | it.dutyOn, it.period); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
George Liu | fcf0810 | 2024-08-22 17:00:05 +0800 | [diff] [blame] | 53 | updatedLEDsDuringLampTest.emplace(ledsAssert, ledsDeAssert); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 54 | return true; |
| 55 | } |
| 56 | return false; |
| 57 | } |
| 58 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 59 | void LampTest::stop() |
| 60 | { |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 61 | if (!isLampTestRunning) |
| 62 | { |
| 63 | return; |
| 64 | } |
| 65 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 66 | timer.setEnabled(false); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 67 | |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 68 | // Stop host lamp test |
| 69 | doHostLampTest(false); |
| 70 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 71 | // Set all the Physical action to Off |
| 72 | for (const auto& path : physicalLEDPaths) |
| 73 | { |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 74 | auto iter = |
| 75 | std::find_if(skipUpdateLEDs.begin(), skipUpdateLEDs.end(), |
| 76 | [&path](const auto& skip) { return skip == path; }); |
| 77 | |
| 78 | if (iter != skipUpdateLEDs.end()) |
| 79 | { |
| 80 | // Skip update physical path |
| 81 | continue; |
| 82 | } |
| 83 | |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 84 | phosphor::led::Manager::drivePhysicalLED(path, Layout::Action::Off, 0, |
| 85 | 0); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 86 | } |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 87 | |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 88 | if (std::filesystem::exists(lampTestIndicator)) |
| 89 | { |
| 90 | if (!std::filesystem::remove(lampTestIndicator)) |
| 91 | { |
| 92 | lg2::error( |
| 93 | "Error removing lamp test on indicator file after lamp test execution."); |
| 94 | } |
| 95 | } |
| 96 | |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 97 | isLampTestRunning = false; |
| 98 | restorePhysicalLedStates(); |
| 99 | } |
| 100 | |
| 101 | Layout::Action LampTest::getActionFromString(const std::string& str) |
| 102 | { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 103 | Layout::Action action = Layout::Action::Off; |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 104 | |
| 105 | if (str == "xyz.openbmc_project.Led.Physical.Action.On") |
| 106 | { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 107 | action = Layout::Action::On; |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 108 | } |
| 109 | else if (str == "xyz.openbmc_project.Led.Physical.Action.Blink") |
| 110 | { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 111 | action = Layout::Action::Blink; |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | return action; |
| 115 | } |
| 116 | |
| 117 | void LampTest::storePhysicalLEDsStates() |
| 118 | { |
| 119 | physicalLEDStatesPriorToLampTest.clear(); |
| 120 | |
| 121 | for (const auto& path : physicalLEDPaths) |
| 122 | { |
Patrick Williams | 605600e | 2023-10-20 11:18:04 -0500 | [diff] [blame] | 123 | auto iter = std::find_if( |
| 124 | skipUpdateLEDs.begin(), skipUpdateLEDs.end(), |
| 125 | [&path](const auto& skipLed) { return skipLed == path; }); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 126 | |
| 127 | if (iter != skipUpdateLEDs.end()) |
| 128 | { |
| 129 | // Physical LEDs will be skipped |
| 130 | continue; |
| 131 | } |
| 132 | |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 133 | // Reverse intercept path, Get the name of each member of physical led |
| 134 | // e.g: path = /xyz/openbmc_project/led/physical/front_fan |
| 135 | // name = front_fan |
| 136 | sdbusplus::message::object_path object_path(path); |
| 137 | auto name = object_path.filename(); |
| 138 | if (name.empty()) |
| 139 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 140 | lg2::error( |
| 141 | "Failed to get the name of member of physical LED path, PATH = {PATH}, NAME = {NAME}", |
| 142 | "PATH", path, "NAME", name); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 143 | continue; |
| 144 | } |
| 145 | |
| 146 | std::string state{}; |
| 147 | uint16_t period{}; |
| 148 | uint8_t dutyOn{}; |
| 149 | try |
| 150 | { |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 151 | auto properties = |
| 152 | phosphor::led::utils::DBusHandler::getAllProperties(path, |
| 153 | phyLedIntf); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 154 | |
| 155 | state = std::get<std::string>(properties["State"]); |
| 156 | period = std::get<uint16_t>(properties["Period"]); |
| 157 | dutyOn = std::get<uint8_t>(properties["DutyOn"]); |
| 158 | } |
Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 159 | catch (const sdbusplus::exception_t& e) |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 160 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 161 | lg2::error( |
| 162 | "Failed to get All properties, ERROR = {ERROR}, PATH = {PATH}", |
| 163 | "ERROR", e, "PATH", path); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 164 | continue; |
| 165 | } |
| 166 | |
| 167 | phosphor::led::Layout::Action action = getActionFromString(state); |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 168 | if (action != phosphor::led::Layout::Action::Off) |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 169 | { |
| 170 | phosphor::led::Layout::LedAction ledAction{ |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 171 | name, action, dutyOn, period, |
| 172 | phosphor::led::Layout::Action::On}; |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 173 | physicalLEDStatesPriorToLampTest.emplace(ledAction); |
| 174 | } |
| 175 | } |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void LampTest::start() |
| 179 | { |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 180 | if (isLampTestRunning) |
| 181 | { |
| 182 | // reset the timer and then return |
| 183 | timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS)); |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 184 | |
| 185 | // Notify host to reset the timer |
| 186 | doHostLampTest(true); |
| 187 | |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 188 | return; |
| 189 | } |
| 190 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 191 | // Get paths of all the Physical LED objects |
George Liu | 785f505 | 2023-07-18 09:38:43 +0800 | [diff] [blame] | 192 | try |
| 193 | { |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 194 | physicalLEDPaths = phosphor::led::utils::DBusHandler::getSubTreePaths( |
| 195 | phyLedPath, phyLedIntf); |
George Liu | 785f505 | 2023-07-18 09:38:43 +0800 | [diff] [blame] | 196 | } |
| 197 | catch (const sdbusplus::exception_t& e) |
| 198 | { |
| 199 | lg2::error( |
| 200 | "Failed to call the SubTreePaths method: {ERROR}, ledPath: {PATH}, ledInterface: {INTERFACE}", |
George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame] | 201 | "ERROR", e, "PATH", phyLedPath, "INTERFACE", phyLedIntf); |
George Liu | 785f505 | 2023-07-18 09:38:43 +0800 | [diff] [blame] | 202 | return; |
| 203 | } |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 204 | |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 205 | // Get physical LEDs states before lamp test |
| 206 | storePhysicalLEDsStates(); |
| 207 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 208 | // restart lamp test, it contains initiate or reset the timer. |
| 209 | timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS)); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 210 | isLampTestRunning = true; |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 211 | |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 212 | // Notify host to start the lamp test |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 213 | doHostLampTest(true); |
| 214 | |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 215 | // Create a file to maintain the state across reboots that Lamp test is on. |
| 216 | // This is required as there was a scenario where it has been found that |
| 217 | // LEDs remains in "on" state if lamp test is triggered and reboot takes |
| 218 | // place. |
| 219 | const auto ledDirectory = lampTestIndicator.parent_path(); |
| 220 | |
| 221 | if (!fs::exists(ledDirectory)) |
| 222 | { |
| 223 | fs::create_directories(ledDirectory); |
| 224 | } |
| 225 | |
George Liu | 8f538d9 | 2024-08-22 15:41:22 +0800 | [diff] [blame] | 226 | std::ofstream ofs(lampTestIndicator.c_str()); |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 227 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 228 | // Set all the Physical action to On for lamp test |
| 229 | for (const auto& path : physicalLEDPaths) |
| 230 | { |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 231 | auto iter = |
| 232 | std::find_if(skipUpdateLEDs.begin(), skipUpdateLEDs.end(), |
| 233 | [&path](const auto& skip) { return skip == path; }); |
| 234 | |
| 235 | if (iter != skipUpdateLEDs.end()) |
| 236 | { |
| 237 | // Skip update physical path |
| 238 | continue; |
| 239 | } |
| 240 | |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 241 | phosphor::led::Manager::drivePhysicalLED(path, Layout::Action::On, 0, |
| 242 | 0); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 243 | } |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | void LampTest::timeOutHandler() |
| 247 | { |
| 248 | // set the Asserted property of lamp test to false |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 249 | if (!groupObj) |
| 250 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 251 | lg2::error("the Group object is nullptr"); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 252 | throw std::runtime_error("the Group object is nullptr"); |
| 253 | } |
| 254 | |
| 255 | groupObj->asserted(false); |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 256 | } |
| 257 | |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 258 | bool LampTest::requestHandler(Group* group, bool value) |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 259 | { |
George Liu | aaa667f | 2024-08-22 17:37:51 +0800 | [diff] [blame] | 260 | if (groupObj == nullptr) |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 261 | { |
George Liu | df3ab7c | 2024-08-22 19:05:27 +0800 | [diff] [blame] | 262 | groupObj = group; |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame] | 263 | } |
| 264 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 265 | if (value) |
| 266 | { |
| 267 | start(); |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 268 | |
| 269 | // Return true in both cases (F -> T && T -> T) |
| 270 | return true; |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 271 | } |
| 272 | else |
| 273 | { |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 274 | if (timer.hasExpired()) |
| 275 | { |
| 276 | stop(); |
| 277 | |
| 278 | // Return true as the request to stop the lamptest is handled |
| 279 | // successfully. |
| 280 | return true; |
| 281 | } |
| 282 | else if (timer.isEnabled()) |
| 283 | { |
| 284 | lg2::info( |
| 285 | "Lamp test is still running. Cannot force stop the lamp test. Asserted is set back to true."); |
| 286 | |
| 287 | // Return false as the request to stop lamptest is not handled as |
| 288 | // the lamptest is still running. |
| 289 | return false; |
| 290 | } |
| 291 | return false; |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 295 | void LampTest::restorePhysicalLedStates() |
| 296 | { |
| 297 | // restore physical LEDs states before lamp test |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 298 | ActionSet ledsDeAssert{}; |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 299 | manager.driveLEDs(physicalLEDStatesPriorToLampTest, ledsDeAssert); |
George Liu | b615162 | 2020-11-23 18:16:18 +0800 | [diff] [blame] | 300 | physicalLEDStatesPriorToLampTest.clear(); |
| 301 | |
| 302 | // restore physical LEDs states during lamp test |
| 303 | while (!updatedLEDsDuringLampTest.empty()) |
| 304 | { |
| 305 | auto& [ledsAssert, ledsDeAssert] = updatedLEDsDuringLampTest.front(); |
| 306 | manager.driveLEDs(ledsAssert, ledsDeAssert); |
| 307 | updatedLEDsDuringLampTest.pop(); |
| 308 | } |
| 309 | } |
| 310 | |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 311 | void LampTest::doHostLampTest(bool value) |
| 312 | { |
| 313 | try |
| 314 | { |
| 315 | PropertyValue assertedValue{value}; |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 316 | phosphor::led::utils::DBusHandler::setProperty( |
| 317 | HOST_LAMP_TEST_OBJECT, "xyz.openbmc_project.Led.Group", "Asserted", |
| 318 | assertedValue); |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 319 | } |
Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 320 | catch (const sdbusplus::exception_t& e) |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 321 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 322 | lg2::error( |
| 323 | "Failed to set Asserted property, ERROR = {ERROR}, PATH = {PATH}", |
| 324 | "ERROR", e, "PATH", std::string(HOST_LAMP_TEST_OBJECT)); |
George Liu | ce4d1c5 | 2021-01-25 11:32:37 +0800 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 328 | void LampTest::getPhysicalLEDNamesFromJson(const fs::path& path) |
| 329 | { |
| 330 | if (!fs::exists(path) || fs::is_empty(path)) |
| 331 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 332 | lg2::info("The file does not exist or is empty, FILE_PATH = {PATH}", |
| 333 | "PATH", path); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 334 | return; |
| 335 | } |
| 336 | |
| 337 | try |
| 338 | { |
| 339 | std::ifstream jsonFile(path); |
| 340 | auto json = Json::parse(jsonFile); |
| 341 | |
| 342 | // define the default JSON as empty |
| 343 | const std::vector<std::string> empty{}; |
| 344 | auto forceLEDs = json.value("forceLEDs", empty); |
George Liu | c5e0f31 | 2021-12-27 15:54:31 +0800 | [diff] [blame] | 345 | std::ranges::transform(forceLEDs, std::back_inserter(forceUpdateLEDs), |
George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame] | 346 | [](const auto& i) { return phyLedPath + i; }); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 347 | |
| 348 | auto skipLEDs = json.value("skipLEDs", empty); |
George Liu | c5e0f31 | 2021-12-27 15:54:31 +0800 | [diff] [blame] | 349 | std::ranges::transform(skipLEDs, std::back_inserter(skipUpdateLEDs), |
George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame] | 350 | [](const auto& i) { return phyLedPath + i; }); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 351 | } |
| 352 | catch (const std::exception& e) |
| 353 | { |
George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 354 | lg2::error( |
| 355 | "Failed to parse config file, ERROR = {ERROR}, FILE_PATH = {PATH}", |
| 356 | "ERROR", e, "PATH", path); |
George Liu | 8215032 | 2021-03-03 17:13:13 +0800 | [diff] [blame] | 357 | } |
| 358 | return; |
| 359 | } |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 360 | |
| 361 | void LampTest::clearLamps() |
| 362 | { |
| 363 | if (std::filesystem::exists(lampTestIndicator)) |
| 364 | { |
| 365 | // we need to off all the LEDs. |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 366 | std::vector<std::string> physicalLedPaths = |
| 367 | phosphor::led::utils::DBusHandler::getSubTreePaths( |
| 368 | phosphor::led::phyLedPath, phosphor::led::phyLedIntf); |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 369 | |
| 370 | for (const auto& path : physicalLedPaths) |
| 371 | { |
George Liu | f059255 | 2024-08-23 09:46:17 +0800 | [diff] [blame^] | 372 | phosphor::led::Manager::drivePhysicalLED( |
| 373 | path, phosphor::led::Layout::Action::Off, 0, 0); |
Sunny Srivastava | e3515c7 | 2022-10-15 12:45:40 -0500 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | // Also remove the lamp test on indicator file. |
| 377 | if (!std::filesystem::remove(lampTestIndicator)) |
| 378 | { |
| 379 | lg2::error( |
| 380 | "Error removing lamp test on indicator file after lamp test execution."); |
| 381 | } |
| 382 | } |
| 383 | } |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 384 | } // namespace led |
| 385 | } // namespace phosphor |