James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "sensor.hpp" |
| 3 | |
| 4 | #include <boost/asio/deadline_timer.hpp> |
| 5 | #include <boost/container/flat_map.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame^] | 6 | |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 7 | #include <chrono> |
| 8 | #include <limits> |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 9 | #include <memory> |
| 10 | #include <optional> |
| 11 | #include <string> |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
| 14 | enum class IpmbType |
| 15 | { |
| 16 | meSensor, |
| 17 | PXE1410CVR, |
| 18 | IR38363VR, |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame] | 19 | ADM1278HSC, |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 20 | mpsVR |
| 21 | }; |
| 22 | |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame] | 23 | enum class IpmbSubType |
| 24 | { |
| 25 | temp, |
| 26 | curr, |
| 27 | power, |
| 28 | volt |
| 29 | }; |
| 30 | |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 31 | struct IpmbSensor : public Sensor |
| 32 | { |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 33 | IpmbSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 34 | boost::asio::io_service& io, const std::string& name, |
| 35 | const std::string& sensorConfiguration, |
| 36 | sdbusplus::asio::object_server& objectServer, |
| 37 | std::vector<thresholds::Threshold>&& thresholds, |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame] | 38 | uint8_t deviceAddress, std::string& sensorTypeName); |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 39 | ~IpmbSensor(); |
| 40 | |
| 41 | void checkThresholds(void) override; |
| 42 | void read(void); |
| 43 | void init(void); |
| 44 | void loadDefaults(void); |
James Feist | f7e2c5d | 2019-02-13 17:27:51 -0800 | [diff] [blame] | 45 | void runInitCmd(void); |
James Feist | 551087a | 2019-12-09 11:17:12 -0800 | [diff] [blame] | 46 | void processError(void); |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 47 | |
| 48 | IpmbType type; |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame] | 49 | IpmbSubType subType; |
| 50 | double scaleVal; |
| 51 | double offsetVal; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 52 | uint8_t commandAddress; |
| 53 | uint8_t netfn; |
| 54 | uint8_t command; |
| 55 | uint8_t deviceAddress; |
James Feist | 551087a | 2019-12-09 11:17:12 -0800 | [diff] [blame] | 56 | uint8_t errorCount; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 57 | std::vector<uint8_t> commandData; |
| 58 | std::optional<uint8_t> initCommand; |
| 59 | std::vector<uint8_t> initData; |
| 60 | |
| 61 | // to date all ipmb sensors are power on only |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 62 | PowerState readState; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 63 | |
| 64 | private: |
James Feist | d870587 | 2019-02-08 13:26:09 -0800 | [diff] [blame] | 65 | sdbusplus::asio::object_server& objectServer; |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 66 | std::shared_ptr<sdbusplus::asio::connection> dbusConnection; |
| 67 | boost::asio::deadline_timer waitTimer; |
Vijay Khemka | 682a5cb | 2019-07-18 17:34:03 -0700 | [diff] [blame] | 68 | }; |