diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-05-09 11:03:14 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-05-16 17:27:46 -0500 |
commit | ee7f64283f2fe728fd4bd67280bf59daaec9df54 (patch) | |
tree | 94df674fdcd96606d10ed55976dffda9d87fa78b /control/main.cpp | |
parent | 389ca67fcd47dbc5375fe9993f3b35ba1af32cff (diff) | |
download | phosphor-fan-presence-ee7f64283f2fe728fd4bd67280bf59daaec9df54.tar.gz phosphor-fan-presence-ee7f64283f2fe728fd4bd67280bf59daaec9df54.zip |
Add modes to phosphor-fan-control
phosphor-fan-control can behave differently based
on its command line arguments
--init: Set fans to full speed, delay for a
configurable amount of time to allow fans to ramp up,
start the fan control ready target, and then exit.
--control: Start the control algorithm. Never exits.
Will be started as part of the fan control ready target.
Change-Id: I453daf8cc05a5c85a19c098e1cca64cac2ad9520
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'control/main.cpp')
-rw-r--r-- | control/main.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/control/main.cpp b/control/main.cpp index 08a7dc9..be5b59e 100644 --- a/control/main.cpp +++ b/control/main.cpp @@ -14,13 +14,46 @@ * limitations under the License. */ #include <sdbusplus/bus.hpp> +#include "argument.hpp" #include "manager.hpp" +using namespace phosphor::fan::control; + int main(int argc, char* argv[]) { auto bus = sdbusplus::bus::new_default(); + phosphor::fan::util::ArgumentParser args(argc, argv); + + if (argc != 2) + { + args.usage(argv); + exit(-1); + } - phosphor::fan::control::Manager manager(bus); + Manager::Mode mode; + + if (args["init"] == "true") + { + mode = Manager::Mode::init; + } + else if (args["control"] == "true") + { + mode = Manager::Mode::control; + } + else + { + args.usage(argv); + exit(-1); + } + + Manager manager(bus, mode); + + //Init mode will just set fans to max and delay + if (mode == Manager::Mode::init) + { + manager.doInit(); + return 0; + } while (true) { |