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 /monitor.hpp | |
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 'monitor.hpp')
-rw-r--r-- | monitor.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/monitor.hpp b/monitor.hpp index 1dcef79..f4b07de 100644 --- a/monitor.hpp +++ b/monitor.hpp @@ -34,6 +34,7 @@ class Monitor : public Evdev * @param[in] target - systemd unit to be started on GPIO * value change * @param[in] event - sd_event handler + * @param[in] continueRun - Whether to continue after key pressed * @param[in] handler - IO callback handler. Defaults to one in this * class * @param[in] useEvDev - Whether to use EvDev to retrieve events @@ -43,11 +44,13 @@ class Monitor : public Evdev decltype(input_event::value) polarity, const std::string& target, EventPtr& event, + bool continueRun, sd_event_io_handler_t handler = Monitor::processEvents, bool useEvDev = true) : Evdev(path, key, event, handler, useEvDev), polarity(polarity), - target(target) {}; + target(target), + continueAfterKeyPress(continueRun) {}; /** @brief Callback handler when the FD has some activity on it * @@ -75,6 +78,9 @@ class Monitor : public Evdev /** @brief Systemd unit to be started when the condition is met */ const std::string& target; + /** @brief If the monitor should continue after key press */ + bool continueAfterKeyPress; + /** @brief Completion indicator */ bool complete = false; |