Added SMART support for Samsung SSDs.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2011-2012
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Collections.Generic;
42 namespace OpenHardwareMonitor.Hardware.HDD {
46 internal class DebugSmart : ISmart {
48 private Drive[] drives = {
49 new Drive("KINGSTON SNV425S264GB", null, 16,
50 @" 01 000000000000 100 100
51 02 000000000000 100 100
52 03 000000000000 100 100
53 05 000000000000 100 100
54 07 000000000000 100 100
55 08 000000000000 100 100
56 09 821E00000000 100 100
57 0A 000000000000 100 100
58 0C 950200000000 100 100
59 A8 000000000000 100 100
60 AF 000000000000 100 100
61 C0 000000000000 100 100
62 C2 290014002B00 100 41
63 C5 000000000000 100 100
64 F0 000000000000 100 100
65 AA 07007B000000 100 100
66 AD 0E1E71304919 100 100"),
68 new Drive("PLEXTOR PX-128M2S", "1.03", 16,
69 @" 01 000000000000 100 100 0
70 03 000000000000 100 100 0
71 04 000000000000 100 100 0
72 05 000000000000 100 100 0
73 09 250100000000 100 100 0
74 0A 000000000000 100 100 0
75 0C D10000000000 100 100 0
76 B2 000000000000 100 100 0
77 BB 000000000000 100 100 0
78 BE 000000000000 100 100 0
79 C0 000000000000 100 100 0
80 C1 000000000000 100 100 0
81 C2 000000000000 100 100 0
82 C3 000000000000 100 100 0
83 C5 000000000000 100 100 0
84 C6 000000000000 100 100 0
85 C7 000000000000 100 100 0"),
87 new Drive("OCZ-VERTEX2", "1.25", 16,
88 @" 01 DADAD5000000 100 106 50
89 05 000000000000 100 100 3
90 09 DF0900004A2F 100 100 0
91 0C FC0100000000 100 100 0
98 BB 000000000000 100 100 0
99 C2 010081007F00 129 1 0
100 C3 DADAD5000000 100 106 0
101 C4 000000000000 100 100 0
102 E7 000000000000 100 100 10
103 E9 800400000000 0 0 0
104 EA 000600000000 0 0 0
105 F1 000600000000 0 0 0
106 F2 801200000000 0 0 0"),
108 new Drive("WDC WD5000AADS-00S9B0", null, 10,
109 @" 1 000000000000 200 200
110 3 820D00000000 149 150
112 5 000000000000 200 200
113 7 000000000000 253 100
115 10 000000000000 100 100
116 11 000000000000 100 100
117 12 880200000000 100 100
118 192 6B0000000000 200 200
119 193 E9CB03000000 118 118
120 194 280000000000 94 103
121 196 000000000000 200 200
122 197 000000000000 200 200
123 198 000000000000 200 200
124 199 000000000000 200 200
125 200 000000000000 200 200
126 130 7B0300010002 1 41
128 1 000000000000 0 0"),
130 new Drive("INTEL SSDSA2M080G2GC", null, 10,
131 @" 3 000000000000 100 100
132 4 000000000000 100 100
133 5 010000000000 100 100
134 9 B10B00000000 100 100
135 12 DD0300000000 100 100
136 192 480000000000 100 100
137 225 89DB00000000 200 200
138 226 3D1B00000000 100 100
139 227 030000000000 100 100
140 228 7F85703C0000 100 100
141 232 000000000000 99 99
142 233 000000000000 98 98
143 184 000000000000 100 100
144 1 000000000000 0 0"),
146 new Drive("OCZ-VERTEX", null, 10,
147 @" 1 000000000000 0 8
154 198 B9ED00000000 214 176
155 199 352701000000 143 185
156 200 B10500000000 105 55
157 201 F40A00000000 238 194
158 202 020000000000 137 35
159 203 020000000000 125 63
161 205 000000000000 19 136
162 206 000000000000 22 54
163 207 010000000000 113 226
164 208 000000000000 49 232
165 209 000000000000 0 98
168 213 000000000000 0 0"),
170 new Drive("INTEL SSDSA2CW120G3", null, 16,
171 @"03 000000000000 100 100 0
172 04 000000000000 100 100 0
173 05 000000000000 100 100 0
174 09 830200000000 100 100 0
175 0C 900100000000 100 100 0
176 AA 000000000000 100 100 0
177 AB 000000000000 100 100 0
178 AC 000000000000 100 100 0
179 B8 000000000000 100 100 0
180 BB 000000000000 100 100 0
181 C0 040000000000 100 100 0
182 E1 FF4300000000 100 100 0
183 E2 E57D14000000 100 100 0
184 E3 000000000000 100 100 0
185 E4 E39600000000 100 100 0
186 E8 000000000000 100 100 0
187 E9 000000000000 100 100 0
188 F1 FF4300000000 100 100 0
189 F2 264F00000000 100 100 0"),
191 new Drive("CORSAIR CMFSSD-128GBG2D", "VBM19C1Q", 16,
192 @"09 100900000000 99 99 0
193 0C 560200000000 99 99 0
194 AF 000000000000 100 100 10
195 B0 000000000000 100 100 10
196 B1 2A0000000000 99 99 17
197 B2 180000000000 60 60 10
198 B3 4B0000000000 98 98 10
199 B4 B50E00000000 98 98 10
200 B5 000000000000 100 100 10
201 B6 000000000000 100 100 10
202 B7 000000000000 100 100 10
203 BB 000000000000 100 100 0
204 C3 000000000000 200 200 0
205 C6 000000000000 100 100 0
206 C7 810100000000 253 253 0
207 E8 240000000000 60 60 10
208 E9 630594120000 92 92 0")
211 public IntPtr OpenDrive(int driveNumber) {
212 if (driveNumber < drives.Length)
213 return (IntPtr)driveNumber;
215 return InvalidHandle;
218 public bool EnableSmart(IntPtr handle, int driveNumber) {
219 if (handle != (IntPtr)driveNumber)
220 throw new ArgumentOutOfRangeException();
225 public DriveAttributeValue[] ReadSmartData(IntPtr handle, int driveNumber) {
226 if (handle != (IntPtr)driveNumber)
227 throw new ArgumentOutOfRangeException();
229 return drives[driveNumber].DriveAttributeValues;
232 public DriveThresholdValue[] ReadSmartThresholds(IntPtr handle,
235 if (handle != (IntPtr)driveNumber)
236 throw new ArgumentOutOfRangeException();
238 return drives[driveNumber].DriveThresholdValues;
241 public bool ReadNameAndFirmwareRevision(IntPtr handle, int driveNumber,
242 out string name, out string firmwareRevision) {
243 if (handle != (IntPtr)driveNumber)
244 throw new ArgumentOutOfRangeException();
246 name = drives[driveNumber].Name;
247 firmwareRevision = drives[driveNumber].FirmwareVersion;
251 public void CloseHandle(IntPtr handle) { }
254 private class Drive {
256 public Drive(string name, string firmware, int idBase, string value) {
258 this.FirmwareVersion = firmware;
260 string[] lines = value.Split(new[] { '\r', '\n' },
261 StringSplitOptions.RemoveEmptyEntries);
263 DriveAttributeValues = new DriveAttributeValue[lines.Length];
264 List<DriveThresholdValue> thresholds = new List<DriveThresholdValue>();
266 for (int i = 0; i < lines.Length; i++) {
268 string[] array = lines[i].Split(new[] { ' ' },
269 StringSplitOptions.RemoveEmptyEntries);
271 if (array.Length != 4 && array.Length != 5)
272 throw new Exception();
274 DriveAttributeValue v = new DriveAttributeValue();
275 v.Identifier = Convert.ToByte(array[0], idBase);
277 v.RawValue = new byte[6];
278 for (int j = 0; j < 6; j++) {
279 v.RawValue[j] = Convert.ToByte(array[1].Substring(2 * j, 2), 16);
282 v.WorstValue = Convert.ToByte(array[2], 10);
283 v.AttrValue = Convert.ToByte(array[3], 10);
285 DriveAttributeValues[i] = v;
287 if (array.Length == 5) {
288 DriveThresholdValue t = new DriveThresholdValue();
289 t.Identifier = v.Identifier;
290 t.Threshold = Convert.ToByte(array[4], 10);
295 DriveThresholdValues = thresholds.ToArray();
298 public DriveAttributeValue[] DriveAttributeValues { get; private set; }
300 public DriveThresholdValue[] DriveThresholdValues { get; private set; }
302 public string Name { get; private set; }
304 public string FirmwareVersion { get; private set; }
307 public IntPtr InvalidHandle { get { return (IntPtr)(-1); } }