blob: a64d708bd9fe012f5da098f26a1ea25f4ad72120 [file] [log] [blame]
Jagpal Singh Gille92aba42025-10-16 00:00:13 -07001#pragma once
2
3#include "base_config.hpp"
4#include "modbus/modbus.hpp"
5#include "port/base_port.hpp"
6
7#include <sdbusplus/async.hpp>
8#include <xyz/openbmc_project/Sensor/Value/aserver.hpp>
9
10namespace phosphor::modbus::rtu::device
11{
12
13class Device;
14
15using SensorValueIntf =
16 sdbusplus::aserver::xyz::openbmc_project::sensor::Value<Device>;
17using PortIntf = phosphor::modbus::rtu::port::BasePort;
18
19class BaseDevice
20{
21 public:
22 BaseDevice() = delete;
23
24 explicit BaseDevice(sdbusplus::async::context& ctx,
25 const config::Config& config, PortIntf& serialPort);
26
27 auto readSensorRegisters() -> sdbusplus::async::task<void>;
28
29 private:
30 auto createSensors() -> void;
31
32 using sensors_map_t =
33 std::unordered_map<std::string, std::unique_ptr<SensorValueIntf>>;
34 sdbusplus::async::context& ctx;
35 const config::Config config;
36 PortIntf& serialPort;
37 sensors_map_t sensors;
38};
39
40} // namespace phosphor::modbus::rtu::device