#ifndef DMM_HID_H_ #define DMM_HID_H_ #include #include #include constexpr int DMM_TIMEOUT_MS = 100; struct Reading { enum reading_type { reading_continuity, reading_diode, reading_percent, reading_volts, reading_amps, reading_ohms, reading_hFE, reading_hertz, reading_farads, reading_celsius, reading_fahrenheit, reading_type_max }; uint8_t value[4]; int8_t modifier; uint8_t dot_pos; bool is_inf; bool is_neg; bool is_DC; bool is_rel; bool is_hold; bool is_min; bool is_max; reading_type type; }; class DMM_HID { private: // File descriptor to DMM device int m_fd; std::mutex m_mutex; public: DMM_HID(); ~DMM_HID(); // Opens the dev file and prepares to get readings // Returns true on success, false on failure void Open(const std::string& dev); // Closes the dev file void Close(); bool is_open(); // Returns all readings since opening or since last call std::vector get_readings(int timeout_ms = DMM_TIMEOUT_MS); // Returns all devpaths to DMM devices static std::vector get_dmm_devices(); // Locks the mutex void lock(); // Unlocks the mutex void unlock(); }; #endif // DMM_H_