Skip to content

Commit 3e2041a

Browse files
committed
Fix Command12.
There are no requirements for lba_* to be unsigned values in 04-262r8.pdf, section 13.2.2. Besides, SMART LBA 0xC24F00 works pretty well with ATA PASS-THROUGH (12) command. Also add getter/setter for lba.
1 parent 4f67183 commit 3e2041a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

smartie/scsi/structures.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,25 @@ class Command12(ctypes.Structure):
276276
("protocol", ctypes.c_ubyte),
277277
("flags", CommandFlags),
278278
("features", ctypes.c_ubyte),
279-
("reserved_1", ctypes.c_ubyte, 1),
280-
("sector_count", ctypes.c_ubyte, 7),
281-
("reserved_2", ctypes.c_ubyte, 1),
282-
("lba_low", ctypes.c_ubyte, 7),
283-
("reserved_3", ctypes.c_ubyte, 1),
284-
("lba_mid", ctypes.c_ubyte, 7),
285-
("reserved_4", ctypes.c_ubyte, 1),
286-
("lba_high", ctypes.c_ubyte, 7),
279+
("sector_count", ctypes.c_ubyte),
280+
("lba_low", ctypes.c_ubyte),
281+
("lba_mid", ctypes.c_ubyte),
282+
("lba_high", ctypes.c_ubyte),
287283
("device", ctypes.c_ubyte),
288284
("command", ctypes.c_ubyte),
289-
("reserved_5", ctypes.c_ubyte),
285+
("reserved", ctypes.c_ubyte),
290286
("control", ctypes.c_ubyte),
291287
]
292288

289+
@property
290+
def lba(self):
291+
return self.lba_low | (self.lba_mid << 8) | (self.lba_high << 16)
292+
293+
@lba.setter
294+
def lba(self, lba: int):
295+
self.lba_high, self.lba_mid, self.lba_low = \
296+
lba.to_bytes(3, byteorder="little")
297+
293298

294299
class Command16(ctypes.BigEndianStructure):
295300
"""

0 commit comments

Comments
 (0)