Enable/Disable some sensors when Host On/Off

Matt Spinler mspinler at linux.ibm.com
Fri Oct 23 02:51:13 AEDT 2020



On 10/22/2020 9:49 AM, Thu Ba Nguyen wrote:
> I started on supporting enable/disable host sensors. Everythings is 
> fine until I...
> This Message Is From an External Sender
> This message came from outside your organization.
>
> I started on supporting enable/disable host sensors.
> Everythings is fine until I add code to monitor host status as below.
> bool MainLoop::isHostOn(void)
> {
> char buff[128];
> if (!powerMatch)
> {
> log<level::ERR>("Power Match Not Created");
> }
> sprintf(buff, "isHostOn powerStatusOn: %d\n",powerStatusOn);
> log<level::INFO>(buff);
> return powerStatusOn;
> }
> std::shared_ptr<sdbusplus::bus::match::match>
> MainLoop::startHostStateMonitor(void) {
> return std::make_shared<sdbusplus::bus::match::match>(
> *conn,
> "type='signal',interface='org.freedesktop.DBus.Properties',"
> "member='PropertiesChanged',arg0='xyz.openbmc_project.State.Host'",
> [](sdbusplus::message::message &msg) {
> std::string interfaceName;
> boost::container::flat_map<std::string, std::variant<std::string>>
> propertiesChanged;
> try {
> msg.read(interfaceName, propertiesChanged);
> } catch (std::exception &e) {
> log<level::ERR>("Unable to read host state\n");
> return;
> }
> // We only want to check for CurrentHostState
> if (propertiesChanged.begin()->first != "CurrentHostState") {
> return;
> }
> auto findState = propertiesChanged.find(powProperty);
> if (findState != propertiesChanged.end())
> {
> powerStatusOn = boost::ends_with(
> std::get<std::string>(findState->second), "Running");
> }
> powerMatch = true;
> });
> }
> void MainLoop::read()
> {
> // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to
> // ensure the objects all exist?
> /* Host changed state from On to Off */
> if (!isHostOn() && (lastPowerState == HOST_ON ||
> lastPowerState == HOST_NA)) {
> removeHostSensors();
> lastPowerState = HOST_OFF;
> }
> /* Host changed state from Off to On */
> if (isHostOn() && lastPowerState == HOST_OFF) {
> addDroppedHostSensors();
> lastPowerState = HOST_ON;
> }
> When build openBMC I got error:
> tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot/lib/libpthread.so.0: 
> error adding symbols: DSO missing from command line
> | collect2: error: ld returned 1 exit status
> | make[2]: *** [Makefile:643: phosphor-hwmon-readd] Error 1
>
> It seems I need adding the threads lib to defend lib.
> Any suggestion to add threads lib to build configuration?
>

That must be because you're using that single boost function?  While you 
could add the dependency,
the ideal thing to do since this repo already uses 
phosphor-dbus-interfaces is to use the function:

         /** @brief Convert a string to an appropriate enum value.
          *  @param[in] s - The string to convert in the form of
          *                 "xyz.openbmc_project.State.Host.<value name>"
          *  @return - The enum value.
          */
         static HostState convertHostStateFromString(const std::string& s);

to convert it to the actual HostState enum to check against:

         enum class HostState
         {
             Off,
             Running,
             Quiesced,
             DiagnosticMode,
         };

This is all in xyz/openbmc_project/State/Host/server.hpp provided by 
phosphor-dbus-interfaces.

> Thanks.
> Thu.
>
> On Wed, Oct 21, 2020 at 11:54 PM Thu Ba Nguyen <tbnguyen1985 at gmail.com 
> <mailto:tbnguyen1985 at gmail.com>> wrote:
>
>     Hi Vijay,
>
>     I took a look on entity-manager and openbmc source.
>     Don't have many companies  using entity-manager model to support
>     sensors.
>
>     Regards
>     Thu Nguyen.
>
>
>     On Wed, Oct 21, 2020 at 7:15 AM Vijay Khemka <vijaykhemka at fb.com
>     <mailto:vijaykhemka at fb.com>> wrote:
>
>         *From: *openbmc
>         <openbmc-bounces+vijaykhemka=fb.com at lists.ozlabs.org
>         <mailto:fb.com at lists.ozlabs.org>> on behalf of Thu Ba Nguyen
>         <tbnguyen1985 at gmail.com <mailto:tbnguyen1985 at gmail.com>>
>         *Date: *Monday, October 19, 2020 at 11:23 AM
>         *To: *Ed Tanous <ed at tanous.net <mailto:ed at tanous.net>>
>         *Cc: *OpenBMC Maillist <openbmc at lists.ozlabs.org
>         <mailto:openbmc at lists.ozlabs.org>>
>         *Subject: *Re: Enable/Disable some sensors when Host On/Off
>
>         Hi Ed Tanous,
>
>         > Thanks for your info,
>
>         > But in your platform we are using phosphor-hwmon to manage
>         sensors.
>
>         > We don't use entity-manager.
>
>         > As I knew we can't use both entity-manager and
>         phosphor-hwmon for one project.
>
>         You can use both but for different sensors. You can decide
>         what sensors to configure
>
>         via EM/dbus-sensors and which one for phosphor-hwmon.
>
>         Regards
>
>         Thu Nguyen.
>



More information about the openbmc mailing list