#ifndef SENSORS_HPP #define SENSORS_HPP #include #include #include #include #include #include #include #include #define IIODEV_SYSFS_PATH_BASE "/sys/bus/iio/devices/iio:device" #define DEV_PATH "/dev/iio:device" namespace filesystem=std::experimental::filesystem::v1; struct scan_t { bool is_le; bool is_signed; uint8_t bits,storagebits; uint8_t shift,repeat; }; class SensorBase { private: int devfd; int workerquit; int readsize; std::function readercb; std::vector> enabled_scan_elem; void enable_buffer(); void parse_type_string(std::string type,scan_t* ti); void readbuffer(); protected: std::string type,sensor_basename; filesystem::path devbufpath; filesystem::path sysfspath; std::unordered_map dict; void enable_scan_element(std::string elem); virtual void enable_scan_elements()=0; virtual void update_values()=0; public: virtual ~SensorBase(){} bool init(int id,std::string _sensor_basename); void deinit(); void reset(); void worker(); void quit_worker(); void set_reader_callback(std::function cb); static std::string get_type(int id); static int detect_sensor(std::string type); }; #endif