diff options
author | Lei YU <mine260309@gmail.com> | 2018-04-11 13:33:25 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2018-04-12 10:13:51 +0800 |
commit | bc4a4ff6e4d0688727d54e73356be617acf18035 (patch) | |
tree | 98156f5981f90cbff29ae809f2419dc18b6ff770 /mainapp.cpp | |
parent | e0573e2e389a3ba1f974ae2ab0c71526634256c8 (diff) | |
download | phosphor-gpio-monitor-bc4a4ff6e4d0688727d54e73356be617acf18035.tar.gz phosphor-gpio-monitor-bc4a4ff6e4d0688727d54e73356be617acf18035.zip |
Add --continue argument
The monitor will exit when key is pressed.
Add --continue argument and if it is set to "true", the monitor will
continue after key is pressed.
This is useful in cases to monitor a button presses.
E.g. It can be used to monitor ID button and start a system unit
everytime when the button is pressed.
This argument is optional so it does not break the current code.
Tested: With "--continue=true", the monitor does not exit when the key
is pressed.
Without the argument of if it is set to other strings, the
monitor exits after the key is pressed.
Change-Id: I4f2ca16d7b26e10397181c83c2c5947ed5ce091f
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'mainapp.cpp')
-rw-r--r-- | mainapp.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mainapp.cpp b/mainapp.cpp index 1dd7e80..9ecaad2 100644 --- a/mainapp.cpp +++ b/mainapp.cpp @@ -62,6 +62,9 @@ int main(int argc, char** argv) // on meeting a condition. auto target = (options)["target"]; + bool continueRun = + (options["continue"] == phosphor::gpio::ArgumentParser::trueString); + sd_event* event = nullptr; auto r = sd_event_default(&event); if (r < 0) @@ -73,8 +76,12 @@ int main(int argc, char** argv) event = nullptr; // Create a monitor object and let it do all the rest - phosphor::gpio::Monitor monitor(path, std::stoi(key), - std::stoi(polarity), target, eventP); + phosphor::gpio::Monitor monitor(path, + std::stoi(key), + std::stoi(polarity), + target, + eventP, + continueRun); // Wait for client requests until this application has processed // at least one expected GPIO state change |