Continue on missing GPIOs in the monitor/presence
In some cases, if a GPIO is not found, the function returns -1 to exit
the process. To improve this, change the return value from -1 to
continue so each object can be handled separately. This ensures
the JSON file fully parses even if some GPIOs are missing.
Change-Id: I83763d56963e3d2ec9981a95a1a0da17d0882910
Signed-off-by: Yang Chen <yang.chen@quantatw.com>
diff --git a/gpioMonMain.cpp b/gpioMonMain.cpp
index 09f92cb..47c4d39 100644
--- a/gpioMonMain.cpp
+++ b/gpioMonMain.cpp
@@ -85,9 +85,6 @@
/* GPIO line */
gpiod_line* line = NULL;
- /* Log message string */
- std::string errMsg;
-
/* GPIO line configuration, default to monitor both edge */
struct gpiod_line_request_config config
{
@@ -135,8 +132,8 @@
if (line == NULL)
{
- lg2::error("Failed to find the {GPIO}", "GPIO", errMsg);
- return -1;
+ lg2::error("Failed to find the {GPIO}", "GPIO", lineMsg);
+ continue;
}
/* Get event to be monitored, if it is not defined then
diff --git a/multi-presence/main.cpp b/multi-presence/main.cpp
index 4b631d9..368f8bb 100644
--- a/multi-presence/main.cpp
+++ b/multi-presence/main.cpp
@@ -134,7 +134,7 @@
if (line == NULL)
{
lg2::error("Failed to find the {GPIO}", "GPIO", lineMsg);
- return -1;
+ continue;
}
/* Parse out inventory argument. */