Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <systemd/sd-bus.h> |
| 5 | |
| 6 | #include <sdbusplus/server.hpp> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace pldm |
| 10 | { |
| 11 | namespace responder |
| 12 | { |
| 13 | |
| 14 | /** |
| 15 | * @brief Get the DBUS Service name for the input dbus path |
| 16 | * @param[in] bus - DBUS Bus Object |
| 17 | * @param[in] path - DBUS object path |
| 18 | * @param[in] interface - DBUS Interface |
| 19 | * @return std::string - the dbus service name |
| 20 | */ |
| 21 | std::string getService(sdbusplus::bus::bus& bus, const std::string& path, |
| 22 | const std::string& interface); |
| 23 | |
| 24 | /** @brief Convert any Decimal number to BCD |
| 25 | * |
| 26 | * @tparam[in] decimal - Decimal number |
| 27 | * @return Corresponding BCD number |
| 28 | */ |
| 29 | template <typename T> |
| 30 | T decimalToBcd(T decimal) |
| 31 | { |
| 32 | T bcd = 0; |
| 33 | T rem = 0; |
| 34 | auto cnt = 0; |
| 35 | |
| 36 | while (decimal) |
| 37 | { |
| 38 | rem = decimal % 10; |
| 39 | bcd = bcd + (rem << cnt); |
| 40 | decimal = decimal / 10; |
| 41 | cnt += 4; |
| 42 | } |
| 43 | |
| 44 | return bcd; |
| 45 | } |
| 46 | |
| 47 | } // namespace responder |
| 48 | } // namespace pldm |