blob: c5548faa8ef24970b14bb60e6de43fd428b601e7 [file] [log] [blame]
James Feist6ef20402019-01-07 16:45:08 -08001#pragma once
2#include "sensor.hpp"
3
4#include <boost/asio/deadline_timer.hpp>
5#include <boost/container/flat_map.hpp>
James Feist38fb5982020-05-28 10:09:54 -07006
James Feist6ef20402019-01-07 16:45:08 -08007#include <chrono>
8#include <limits>
Patrick Venturefd6ba732019-10-31 14:27:39 -07009#include <memory>
10#include <optional>
11#include <string>
James Feist6ef20402019-01-07 16:45:08 -080012#include <vector>
13
14enum class IpmbType
15{
16 meSensor,
17 PXE1410CVR,
18 IR38363VR,
Vijay Khemka682a5cb2019-07-18 17:34:03 -070019 ADM1278HSC,
James Feist6ef20402019-01-07 16:45:08 -080020 mpsVR
21};
22
Vijay Khemka682a5cb2019-07-18 17:34:03 -070023enum class IpmbSubType
24{
25 temp,
26 curr,
27 power,
28 volt
29};
30
James Feist6ef20402019-01-07 16:45:08 -080031struct IpmbSensor : public Sensor
32{
James Feistd8705872019-02-08 13:26:09 -080033 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 Khemka682a5cb2019-07-18 17:34:03 -070038 uint8_t deviceAddress, std::string& sensorTypeName);
James Feist6ef20402019-01-07 16:45:08 -080039 ~IpmbSensor();
40
41 void checkThresholds(void) override;
42 void read(void);
43 void init(void);
44 void loadDefaults(void);
James Feistf7e2c5d2019-02-13 17:27:51 -080045 void runInitCmd(void);
James Feist551087a2019-12-09 11:17:12 -080046 void processError(void);
James Feist6ef20402019-01-07 16:45:08 -080047
48 IpmbType type;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070049 IpmbSubType subType;
50 double scaleVal;
51 double offsetVal;
James Feist6ef20402019-01-07 16:45:08 -080052 uint8_t commandAddress;
53 uint8_t netfn;
54 uint8_t command;
55 uint8_t deviceAddress;
James Feist551087a2019-12-09 11:17:12 -080056 uint8_t errorCount;
James Feist6ef20402019-01-07 16:45:08 -080057 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 Feist52497fd2019-06-07 13:01:33 -070062 PowerState readState;
James Feist6ef20402019-01-07 16:45:08 -080063
64 private:
James Feistd8705872019-02-08 13:26:09 -080065 sdbusplus::asio::object_server& objectServer;
James Feist6ef20402019-01-07 16:45:08 -080066 std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
67 boost::asio::deadline_timer waitTimer;
Vijay Khemka682a5cb2019-07-18 17:34:03 -070068};