如何使oshi.hardware.传感器信息可用.能做到吗



我试图使用OSHI获取cpu温度、电压和风扇速度,但结果显示此信息不可用。这是我的代码:

public static void main(String... args) {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
Sensors sensors = hal.getSensors();
System.out.println(sensors.toString());
}

这是Windows 10上的输出:

CPU Temperature=0.0°C, Fan Speeds=[0, 0, 0], CPU Voltage=0.0

这是传感器界面:

public interface Sensors {
/**
* CPU Temperature
*
* @return CPU Temperature in degrees Celsius if available, 0 otherwise.
*/
double getCpuTemperature();
/**
* Fan speeds
*
* @return Speed in rpm for all fans. May return empty array if no fans detected
*         or 0 fan speed if unable to measure fan speed.
*/
int[] getFanSpeeds();
/**
* CPU Voltage
*
* @return CPU Voltage in Volts if available, 0 otherwise.
*/
double getCpuVoltage();
}

如果信息不可用,接口中的三个函数将返回0。

我的问题是,你能提供这些信息吗?如果可以,如何提供?

我找到了一个解释:

Windows传感器(温度、风扇、电压(读数来自微软的Windows Management Instrumentation(WMI(API;然而,大多数硬件制造商并不向WMI发布这些读数。如果某个值无法通过Microsoft API获得,如果Open Hardware Monitor正在运行,Oshi将尝试检索其发布的值。使用coretemp在FreeBSD上只检测到温度传感器。

我试着用OHM运行它,它对温度有效,这对我来说已经足够了。如果你能找到其他两个变量的方法,请告诉我。

最新更新