@@ -52,8 +52,9 @@ int get_connection(sd_bus *bus, char *connection, const char *obj_path)
52
52
"GetObject" ,
53
53
& bus_error ,
54
54
& m ,
55
- "s" ,
56
- obj_path );
55
+ "ss" ,
56
+ obj_path ,
57
+ "" );
57
58
if (rc < 0 ) {
58
59
fprintf (stderr ,
59
60
"Failed to GetObject: %s\n" , bus_error .message );
@@ -90,13 +91,12 @@ int set_dbus_sensor(sd_bus *bus, const char *obj_path, int val)
90
91
goto finish ;
91
92
}
92
93
93
- rc = sd_bus_call_method (bus ,
94
+ rc = sd_bus_set_property (bus ,
94
95
connection ,
95
96
obj_path ,
96
- "org.openbmc.SensorValue " ,
97
- "setValue " ,
97
+ "xyz.openbmc_project.Control.FanSpeed " ,
98
+ "Target " ,
98
99
& bus_error ,
99
- & response ,
100
100
"i" ,
101
101
val );
102
102
if (rc < 0 )
@@ -112,8 +112,8 @@ int set_dbus_sensor(sd_bus *bus, const char *obj_path, int val)
112
112
return rc ;
113
113
}
114
114
115
- /* Read sensor value from "org.openbmc .Sensors" */
116
- int read_dbus_sensor (sd_bus * bus , const char * obj_path )
115
+ /* Read sensor value from "xyz.openbmc_projects .Sensors" */
116
+ int read_dbus_sensor (sd_bus * bus , const char * obj_path , const char * property )
117
117
{
118
118
char connection [DBUS_MAX_NAME_LEN ];
119
119
sd_bus_error bus_error = SD_BUS_ERROR_NULL ;
@@ -132,14 +132,14 @@ int read_dbus_sensor(sd_bus *bus, const char *obj_path)
132
132
goto finish ;
133
133
}
134
134
135
- rc = sd_bus_call_method (bus ,
135
+ rc = sd_bus_get_property (bus ,
136
136
connection ,
137
137
obj_path ,
138
- "org.openbmc.SensorValue " ,
139
- "getValue" ,
138
+ "xyz.openbmc_project.Sensor.Value " ,
139
+ property ,
140
140
& bus_error ,
141
141
& response ,
142
- NULL );
142
+ "i" );
143
143
if (rc < 0 ) {
144
144
val = 0 ;
145
145
fprintf (stderr ,
@@ -148,7 +148,7 @@ int read_dbus_sensor(sd_bus *bus, const char *obj_path)
148
148
goto finish ;
149
149
}
150
150
151
- rc = sd_bus_message_read (response , "v" , " i" , & val );
151
+ rc = sd_bus_message_read (response , "i" , & val );
152
152
if (rc < 0 ) {
153
153
val = 0 ;
154
154
fprintf (stderr ,
@@ -165,7 +165,7 @@ int read_dbus_sensor(sd_bus *bus, const char *obj_path)
165
165
return val ;
166
166
}
167
167
168
- /* set fan speed with /org/openbmc /sensors/speed /fan* object */
168
+ /* set fan speed with /xyz/openbmc_project /sensors/fan_tach /fan* object */
169
169
static int fan_set_speed (sd_bus * bus , int fan_id , uint8_t fan_speed )
170
170
{
171
171
char obj_path [DBUS_MAX_NAME_LEN ];
@@ -175,7 +175,7 @@ static int fan_set_speed(sd_bus *bus, int fan_id, uint8_t fan_speed)
175
175
return -1 ;
176
176
177
177
snprintf (obj_path , sizeof (obj_path ),
178
- "/org/openbmc /sensors/speed /fan%d " , fan_id );
178
+ "/xyz/openbmc_project /sensors/fan_tach /fan%d_0 " , fan_id );
179
179
rc = set_dbus_sensor (bus , obj_path , fan_speed );
180
180
if (rc < 0 )
181
181
fprintf (stderr , "fanctl: Failed to set fan[%d] speed[%d]\n" ,
@@ -215,13 +215,10 @@ static int fan_get_speed(sd_bus *bus, int fan_id)
215
215
int fan_speed ;
216
216
217
217
/* get fan tach */
218
- /* The object path is specific to Barreleye */
219
218
snprintf (obj_path , sizeof (obj_path ),
220
- "/org/openbmc/sensors/tach/fan%dH" , fan_id );
221
- fan_tach_H = read_dbus_sensor (bus , obj_path );
222
- snprintf (obj_path , sizeof (obj_path ),
223
- "/org/openbmc/sensors/tach/fan%dL" , fan_id );
224
- fan_tach_L = read_dbus_sensor (bus , obj_path );
219
+ "/xyz/openbmc_project/sensors/fan_tach/fan%d_0" , fan_id );
220
+ fan_tach_H = read_dbus_sensor (bus , obj_path , "MaxValue" );
221
+ fan_tach_L = read_dbus_sensor (bus , obj_path , "MinValue" );
225
222
226
223
/* invalid sensor value is -1 */
227
224
if (fan_tach_H <= 0 || fan_tach_L <= 0 )
@@ -243,7 +240,8 @@ int fan_set_present(sd_bus *bus, int fan_id, int val)
243
240
char connection [DBUS_MAX_NAME_LEN ];
244
241
245
242
snprintf (obj_path , sizeof (obj_path ),
246
- "/org/openbmc/inventory/system/chassis/fan%d" , fan_id );
243
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/fan%d" ,
244
+ fan_id );
247
245
248
246
rc = get_connection (bus , connection , obj_path );
249
247
if (rc < 0 ) {
@@ -252,15 +250,14 @@ int fan_set_present(sd_bus *bus, int fan_id, int val)
252
250
goto finish ;
253
251
}
254
252
255
- rc = sd_bus_call_method (bus ,
253
+ rc = sd_bus_set_property (bus ,
256
254
connection ,
257
255
obj_path ,
258
- "org.openbmc.InventoryItem " ,
259
- "setPresent " ,
256
+ "xyz.openbmc_project.Inventory.Item " ,
257
+ "Present " ,
260
258
& bus_error ,
261
- & response ,
262
- "s" ,
263
- (val == 1 ? "True" : "False" ));
259
+ "b" ,
260
+ val );
264
261
if (rc < 0 )
265
262
fprintf (stderr ,
266
263
"fanctl: Failed to update fan presence via dbus: %s\n" ,
0 commit comments