@@ -94,9 +94,7 @@ class CSW:
94
94
STATUS_FAILED = const (1 )
95
95
STATUS_PHASE_ERROR = const (2 )
96
96
97
- def __init__ (
98
- self , dCSWSignature = 0x53425355 , dCSWTag = None , dCSWDataResidue = 0 , bCSWStatus = 0
99
- ):
97
+ def __init__ (self , dCSWSignature = 0x53425355 , dCSWTag = None , dCSWDataResidue = 0 , bCSWStatus = 0 ):
100
98
self .dCSWSignature = dCSWSignature
101
99
self .dCSWTag = dCSWTag
102
100
self .dCSWDataResidue = dCSWDataResidue
@@ -199,9 +197,7 @@ def try_to_prepare_cbw(self, args=None):
199
197
try :
200
198
self .prepare_cbw ()
201
199
except KeyError :
202
- self .timer .init (
203
- mode = Timer .ONE_SHOT , period = 2000 , callback = self .try_to_prepare_cbw
204
- )
200
+ self .timer .init (mode = Timer .ONE_SHOT , period = 2000 , callback = self .try_to_prepare_cbw )
205
201
206
202
def handle_interface_control_xfer (self , stage , request ):
207
203
"""Handle the interface control transfers; reset and get max lun"""
@@ -286,9 +282,7 @@ def prepare_cbw(self, args=None):
286
282
def receive_cbw_callback (self , ep_addr , result , xferred_bytes ):
287
283
"""Callback stub to schedule actual CBW processing"""
288
284
self .log ("receive_cbw_callback" )
289
- micropython .schedule (
290
- self .proc_receive_cbw_callback , (ep_addr , result , xferred_bytes )
291
- )
285
+ micropython .schedule (self .proc_receive_cbw_callback , (ep_addr , result , xferred_bytes ))
292
286
293
287
def proc_receive_cbw_callback (self , args ):
294
288
"""Invoke CBW processing"""
@@ -378,9 +372,7 @@ def proc_transfer_data(self, args):
378
372
return micropython .schedule (self .send_csw , None )
379
373
380
374
# This is the last data we're sending, pad it out
381
- residue = self .cbw .dCBWDataTransferLength - (
382
- self .transferred_length + len (self .data )
383
- )
375
+ residue = self .cbw .dCBWDataTransferLength - (self .transferred_length + len (self .data ))
384
376
if residue :
385
377
self .log (f"Adding { residue } bytes of padding for residue" )
386
378
self .csw .dCSWDataResidue = residue
@@ -418,9 +410,7 @@ def validate_cbw(self) -> bool:
418
410
# Check if this is a valid SCSI command
419
411
try :
420
412
# The storage layer doesn't know about USB, it'll return True for valid and False for invalid
421
- return not self .storage_device .validate_cmd (
422
- self .cbw .CBWCB [0 : self .cbw .bCBWCBLength ]
423
- )
413
+ return not self .storage_device .validate_cmd (self .cbw .CBWCB [0 : self .cbw .bCBWCBLength ])
424
414
except Exception as exc :
425
415
self .log (str (exc ))
426
416
raise
@@ -442,13 +432,9 @@ def send_csw(self, args):
442
432
443
433
# If the host sent a command that was expecting more than just a CSW, we may have to send them some nothing in the absence of being able to STALL
444
434
if self .transferred_length == 0 and self .csw .dCSWDataResidue != 0 :
445
- self .log (
446
- f"Sending { self .csw .dCSWDataResidue } bytes of nothing to pad it out"
447
- )
435
+ self .log (f"Sending { self .csw .dCSWDataResidue } bytes of nothing to pad it out" )
448
436
self .transferred_length = self .csw .dCSWDataResidue
449
- self .submit_xfer (
450
- self .ep_in , bytearray (self .csw .dCSWDataResidue ), self .padding_sent
451
- )
437
+ self .submit_xfer (self .ep_in , bytearray (self .csw .dCSWDataResidue ), self .padding_sent )
452
438
# The flow from sending the CSW happens in the callback, not in whatever called us, so we can just return and re-call from the padding callback
453
439
return
454
440
@@ -649,9 +635,7 @@ def handle_read10(self, cmd=None):
649
635
length = self .long_operation ["remaining_length" ]
650
636
lba = self .long_operation ["current_lba" ]
651
637
else :
652
- (read10 , flags , lba , group , length , control ) = ustruct .unpack (
653
- ">BBLBHB" , cmd
654
- )
638
+ (read10 , flags , lba , group , length , control ) = ustruct .unpack (">BBLBHB" , cmd )
655
639
656
640
# Do we have an AbstractBlockDev?
657
641
if getattr (self .filesystem , "readblocks" , False ):
@@ -719,6 +703,4 @@ def handle_inquiry(self, cmd):
719
703
)
720
704
721
705
self .sense = type (self ).INVALID_COMMAND
722
- raise StorageDevice .StorageError (
723
- "EVPD not implemented" , status = CSW .STATUS_FAILED
724
- )
706
+ raise StorageDevice .StorageError ("EVPD not implemented" , status = CSW .STATUS_FAILED )
0 commit comments