rtu: implement modbus sensor read

Read the modbus device config from the Entity Manager configuration and
create the sensor interfaces for related sensor register config.

Tested:
Added new Unit test named test_sensors -
```
> meson test -t 10 -C builddir/ --print-errorlogs --wrapper="valgrind --error-exitcode=1" test_sensors
ninja: Entering directory `/host/repos/Modbus/phosphor-modbus/builddir'
[2/2] Linking target tests/test_sensors
1/1 test_sensors        OK              13.98s

Ok:                1
Fail:              0
```

Tested on Qemu using Mock Modbus Device -
```
root@ventura:~# busctl tree xyz.openbmc_project.ModbusRTU
└─ /xyz
  └─ /xyz/openbmc_project
    ├─ /xyz/openbmc_project/inventory_source
    │ ├─ /xyz/openbmc_project/inventory_source/Heat_Exchanger_12_DevTTYUSB0
    │ ├─ /xyz/openbmc_project/inventory_source/Heat_Exchanger_12_DevTTYUSB1
    │ ├─ /xyz/openbmc_project/inventory_source/Reservoir_Pumping_Unit_12_DevTTYUSB0
    │ └─ /xyz/openbmc_project/inventory_source/Reservoir_Pumping_Unit_12_DevTTYUSB1
    └─ /xyz/openbmc_project/sensors
      └─ /xyz/openbmc_project/sensors/temperature
        ├─ /xyz/openbmc_project/sensors/temperature/Reservoir_Pumping_Unit_12_DevTTYUSB0_RPU_Coolant_Inlet_Temp_C
        ├─ /xyz/openbmc_project/sensors/temperature/Reservoir_Pumping_Unit_12_DevTTYUSB0_RPU_Coolant_Outlet_Temp_C
        ├─ /xyz/openbmc_project/sensors/temperature/Reservoir_Pumping_Unit_12_DevTTYUSB1_RPU_Coolant_Inlet_Temp_C
        └─ /xyz/openbmc_project/sensors/temperature/Reservoir_Pumping_Unit_12_DevTTYUSB1_RPU_Coolant_Outlet_Temp_C

busctl introspect xyz.openbmc_project.ModbusRTU /xyz/openbmc_project/sensors/temperature/Reservoir_Pumping_Unit_12_DevTTYUSB1_RPU_Coolant_Outlet_Temp_C
NAME                                TYPE      SIGNATURE RESULT/VALUE                             FLAGS
org.freedesktop.DBus.Introspectable interface -         -                                        -
.Introspect                         method    -         s                                        -
org.freedesktop.DBus.Peer           interface -         -                                        -
.GetMachineId                       method    -         s                                        -
.Ping                               method    -         -                                        -
org.freedesktop.DBus.Properties     interface -         -                                        -
.Get                                method    ss        v                                        -
.GetAll                             method    s         a{sv}                                    -
.Set                                method    ssv       -                                        -
.PropertiesChanged                  signal    sa{sv}as  -                                        -
xyz.openbmc_project.Sensor.Value    interface -         -                                        -
.MaxValue                           property  d         nan                                      emits-change writable
.MinValue                           property  d         nan                                      emits-change writable
.Unit                               property  s         "xyz.openbmc_project.Sensor.Value.Unit.… emits-change writable
.Value                              property  d         1670.6                                   emits-change writable
```

Change-Id: I1368e8df5999b5cee9ac19d185ee110a9ecc3021
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/rtu/device/base_config.hpp b/rtu/device/base_config.hpp
new file mode 100644
index 0000000..595c0df
--- /dev/null
+++ b/rtu/device/base_config.hpp
@@ -0,0 +1,102 @@
+#pragma once
+
+#include "modbus/modbus.hpp"
+
+#include <xyz/openbmc_project/Sensor/Value/client.hpp>
+
+namespace phosphor::modbus::rtu::device
+{
+
+namespace ModbusIntf = phosphor::modbus::rtu;
+
+namespace config
+{
+
+using SensorValueIntf =
+    sdbusplus::client::xyz::openbmc_project::sensor::Value<>;
+
+enum class SensorFormat
+{
+    floatingPoint,
+    integer,
+    unknown
+};
+
+struct SensorRegister
+{
+    std::string name = "unknown";
+    std::string pathSuffix = "unknown";
+    SensorValueIntf::Unit unit;
+    uint16_t offset = 0;
+    uint8_t size = 0;
+    uint8_t precision = 0;
+    double scale = 1.0;
+    double shift = 0.0;
+    bool isSigned = false;
+    SensorFormat format = SensorFormat::unknown;
+};
+
+enum class StatusType
+{
+    controllerFailure,
+    fanFailure,
+    filterFailure,
+    powerFault,
+    pumpFailure,
+    leakDetectedCritical,
+    leakDetectedWarning,
+    sensorFailure,
+    sensorReadingCritical,
+    sensorReadingWarning,
+    unknown
+};
+
+struct StatusBit
+{
+    std::string name = "unknown";
+    StatusType type = StatusType::unknown;
+    uint8_t bitPosition = 0;
+    bool value = false;
+};
+
+enum class FirmwareRegisterType
+{
+    version,
+    update,
+    unknown
+};
+
+struct FirmwareRegister
+{
+    std::string name = "unknown";
+    FirmwareRegisterType type = FirmwareRegisterType::unknown;
+    uint16_t offset = 0;
+    uint8_t size = 0;
+};
+
+struct Config
+{
+    using sensor_registers_t = std::vector<SensorRegister>;
+    using status_registers_t =
+        std::unordered_map<uint16_t, std::vector<StatusBit>>;
+    using firmware_registers_t = std::vector<FirmwareRegister>;
+
+    uint8_t address = 0;
+    ModbusIntf::Parity parity = ModbusIntf::Parity::unknown;
+    uint32_t baudRate = 0;
+    std::string name = "unknown";
+    std::string portName = "unknown";
+    sdbusplus::message::object_path inventoryPath;
+    sensor_registers_t sensorRegisters;
+    status_registers_t statusRegisters;
+    firmware_registers_t firmwareRegisters;
+};
+
+auto updateBaseConfig(sdbusplus::async::context& ctx,
+                      const sdbusplus::message::object_path& objectPath,
+                      const std::string& interfaceName, Config& config)
+    -> sdbusplus::async::task<bool>;
+
+} // namespace config
+
+} // namespace phosphor::modbus::rtu::device