Enable/Disable some sensors when Host On/Off

Thu Ba Nguyen tbnguyen1985 at gmail.com
Fri Oct 23 01:49:42 AEDT 2020


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?

Thanks.
Thu.

On Wed, Oct 21, 2020 at 11:54 PM Thu Ba Nguyen <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> wrote:
>
>>
>>
>>
>>
>> *From: *openbmc <openbmc-bounces+vijaykhemka=fb.com at lists.ozlabs.org> on
>> behalf of Thu Ba Nguyen <tbnguyen1985 at gmail.com>
>> *Date: *Monday, October 19, 2020 at 11:23 AM
>> *To: *Ed Tanous <ed at tanous.net>
>> *Cc: *OpenBMC Maillist <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.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20201022/07dc210e/attachment.htm>


More information about the openbmc mailing list