Skip to content

Commit cb4ec03

Browse files
authoredNov 22, 2024··
Merge pull request #23 from yangfl/main
Use BigEndianStructure for Command16.
2 parents dc59fca + 5652d32 commit cb4ec03

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed
 

‎smartie/scsi/__init__.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ def smart_thresholds(self) -> Tuple[SmartThresholdResponse, SCSIResponse]:
235235
t_dir=True,
236236
ck_cond=True,
237237
),
238-
features=smartie.structures.swap_int(
239-
2, ATASmartFeature.SMART_READ_THRESHOLDS
240-
),
238+
features=ATASmartFeature.SMART_READ_THRESHOLDS,
241239
).set_lba(0xC24F00)
242240

243241
response = self.issue_command(Direction.FROM, command16, thresholds)
@@ -259,9 +257,7 @@ def smart(self) -> Tuple[SmartDataResponse, SCSIResponse]:
259257
t_dir=True,
260258
ck_cond=True,
261259
),
262-
features=smartie.structures.swap_int(
263-
2, ATASmartFeature.SMART_READ_DATA
264-
),
260+
features=ATASmartFeature.SMART_READ_DATA,
265261
).set_lba(0xC24F00)
266262

267263
response = self.issue_command(Direction.FROM, command16, smart)

‎smartie/scsi/structures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class Command12(ctypes.Structure):
291291
]
292292

293293

294-
class Command16(ctypes.Structure):
294+
class Command16(ctypes.BigEndianStructure):
295295
"""
296296
A 16-byte SCSI/ATA passthrough command.
297297

‎smartie/structures.py

-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ def swap_bytes(src):
4040
return src
4141

4242

43-
def swap_int(c: int, n: int) -> int:
44-
return int.from_bytes(
45-
n.to_bytes(c, byteorder="little"), byteorder="big", signed=False
46-
)
47-
48-
4943
def embed_bytes(data: bytes, *, indent=0, char=" ", max_width=80) -> str:
5044
"""
5145
Pretty-prints `data` in such a way that it can be embedded cleanly in

0 commit comments

Comments
 (0)
Please sign in to comment.