How to get the return value using the command busctl set-property?

Bruce Lee (李昀峻) Bruce_Lee at quantatw.com
Fri Apr 16 14:46:00 AEST 2021


Does busctl set-property can get its return value?
I use the below command, and I found it has no return value.
Dose set-property does not provide a return message like the get-property function?
If can get its return value from set-property, how to do it?

i.e.
busctl set-property xyz.openbmc_project.Hwmon-3687764522.Hwmon1 /xyz/openbmc_project/sensors/voltage/vbat xyz.openbmc_project.Sensor.Value Value d 22
or
in bmcweb the code as below:
i.e.
crow::connections::systemBus->async_method_call(
	[sensorAsyncResp](const boost::system::error_code ec) {
		if (ec)
        {
			BMCWEB_LOG_DEBUG
				<< "setOverrideValueStatus DBUS error: "<< ec;
			messages::internalError(sensorAsyncResp->res);
			return;
		}
	},
	item.second, item.first,
	"org.freedesktop.DBus.Properties", "Set",
	"xyz.openbmc_project.Sensor.Value", "Value",
	std::variant<double>(iterator->second.first));

in dbus-monitor --system I also not found its return value when I use set-property 
dbus-monitor message as below:
method call time=1618547183.313540 sender=:1.87 -> destination=xyz.openbmc_project.Hwmon-3687764522.Hwmon1 serial=2 path=/xyz/openbmc_project/sensors/voltage/vbat; interfa
   string "xyz.openbmc_project.Sensor.Value"                                                                                                                               
   string "Value"                                                                                                                                                          
   variant       double 22                                                                                                                                                 
method call time=1618547183.317152 sender=:1.45 -> destination=org.freedesktop.DBus serial=35 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetConnect
   string ":1.87"                                                                                                                                                          
method return time=1618547183.317937 sender=org.freedesktop.DBus -> destination=:1.45 serial=4294967295 reply_serial=35                                                    
   uint32 0                                                                                                                                                                
method return time=1618547183.330441 sender=:1.45 -> destination=:1.87 serial=36 reply_serial=2  

The set-property code as below: 
int setSensorValue(const double& newValue, double& oldValue)
    {
            
        if (!internalSet)
        {  
            oldValue = newValue;
            overriddenState = true;
            // check thresholds for external set
            value = newValue;
            checkThresholds();
        }
        else if (!overriddenState)
        {
            oldValue = newValue;
        }
        return 1;
    }

sensorInterface->register_property(
	"Value", value, [&](const double& newValue, double& oldValue) {
	return setSensorValue(newValue, oldValue);
});

Thanks,
Bruce.


More information about the openbmc mailing list