Catch the error on set_value call
Sometimes the adcsensor crashes with the below error:
terminate called after throwing an instance of 'std::system_error'
what(): error setting GPIO line values: Operation not permitted
Aborted (core dumped)
Catch such error to prevent service from crash.
Tested:
Change the threshold values on ADC sensor P3VBAT,
No such crash error
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
Change-Id: I05bebb792fc40f458033decd1cca3508af5b770c
diff --git a/include/ADCSensor.hpp b/include/ADCSensor.hpp
index dfd8713..e1f1330 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -42,7 +42,14 @@
{
if (line)
{
- line.set_value(value);
+ try
+ {
+ line.set_value(value);
+ }
+ catch (std::system_error& exc)
+ {
+ std::cerr << "Error set_value: " << exc.what() << "\n";
+ }
}
}