我正在编写一个SMART监控工具,我设法通过SMART_REA_DATA命令获取SMART属性[Current,Worst,Raw Data],但我也需要阈值,我搜索了ATA documentation但我还没找到关于如何读取阈值的任何事情。有谁知道从哪里可以获得这些价值观?
答案 0 :(得分:0)
我找到了答案:)很简单。要获得阈值,必须在Feature寄存器中使用 0xD1 ,并将其余部分配置为0xD0(SMART_READ_DATA)命令。我没有找到它,因为0xD1它是一个过时的功能......但它似乎仍然在新的硬盘驱动器中使用。
结果的结构可以是这样的:
public static void main(String[] args) {
chooseNum();
}
public static void chooseNum() {
int number = 4;
do {
System.out.println("Enter a number 1 to 10");
int userNum = in.nextInt();
if (number == userNum) {
System.out.println("You chose the correct number!");
} else if (number != userNum) {
System.out.println("You chose the incorrect number!");
} else
System.out.println("invalid Response");
}
while (tryAgain());
}
public static boolean tryAgain(){
do {
System.out.println("Try again? yes/no");
String response = in.nextLine();
if (response.equalsIgnoreCase("yes")){
return true;
}else if (response.equalsIgnoreCase("no")){
return false;
}else
System.out.println("Invalid response.");
}
} while(true);
}
用于检索属性阈值的函数:
SMART_ATTRIBUTE = packed record
ID: Byte;
case byte of
0: (Flags: Word;
CurrValue: Byte;
WorstValue: Byte;
RawData: array [0..5] of Byte;
Reserved0: Byte;);
1: (Threshold: Byte;
Reserved1: array [0..9] of Byte;);
end;
SMART_DATA = packed record
Version: Word;
Attribute: array [0..29] of SMART_ATTRIBUTE;
end;