aboutsummaryrefslogtreecommitdiff
path: root/sensors.hpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2018-07-11 11:05:55 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2018-07-11 11:05:55 +0800
commit37ba32b0bbb368a392d2e10b11e45fbde3126e69 (patch)
tree9df0348ccb4e87b2d7c95821a5cd7d3a0f8c1c89 /sensors.hpp
parentb5932d1d22d35cef95eb1cffbf489619b264442d (diff)
downloadlightsd-37ba32b0bbb368a392d2e10b11e45fbde3126e69.tar.xz
Manual mode added.
Quit gracefully. Multiple code clean-ups in the Sensor class.
Diffstat (limited to 'sensors.hpp')
-rw-r--r--sensors.hpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/sensors.hpp b/sensors.hpp
index 7b549ba..91874bd 100644
--- a/sensors.hpp
+++ b/sensors.hpp
@@ -1,3 +1,5 @@
+//Chris Xiong 2018
+//3-Clause BSD License
#ifndef SENSORS_HPP
#define SENSORS_HPP
#include <cstdint>
@@ -5,12 +7,14 @@
#include <any>
#include <filesystem>
#include <functional>
+#include <mutex>
#include <unordered_map>
#include <tuple>
#include <vector>
#define IIODEV_SYSFS_PATH_BASE "/sys/bus/iio/devices/iio:device"
#define DEV_PATH "/dev/iio:device"
+#define PLATFORM_IS_LITTLEENDIAN (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__)
namespace filesystem=std::filesystem;
@@ -25,9 +29,12 @@ struct scan_t
class SensorBase
{
private:
- int devfd;
- int workerquit;
- int readsize;
+ int devfd=-1;
+ int workerquit=0;
+ int readsize=0;
+ int paused=0;
+ int qpipe[2];
+ std::mutex read_m;
std::function<void(SensorBase*)> readercb;
std::vector<std::tuple<int,std::string,scan_t>> enabled_scan_elem;
@@ -51,6 +58,8 @@ class SensorBase
void reset();
void worker();
void quit_worker();
+ void pause_worker();
+ void resume_worker();
void set_reader_callback(std::function<void(SensorBase*)> cb);
static std::string get_type(int id);
static int detect_sensor(std::string type);