@@ -380,6 +380,7 @@ def on_reset(self):
380
380
381
381
def on_open (self ):
382
382
"""Handle USB configuration event."""
383
+ super ().on_open ()
383
384
# Submit initial OUT transfer to receive commands
384
385
self ._submit_out_transfer ()
385
386
@@ -389,9 +390,10 @@ def is_open(self):
389
390
390
391
def _submit_out_transfer (self ):
391
392
"""Submit an OUT transfer to receive data."""
392
- if not super ().is_open ():
393
+ if ( not super ().is_open ()) or self . xfer_pending ( self . _bulk_out_ep ):
393
394
return
394
395
396
+ print ("submit_xfer" )
395
397
self .submit_xfer (self ._bulk_out_ep , self ._rx_packet , self ._on_data_received )
396
398
397
399
def _on_data_received (self , ep , res , num_bytes ):
@@ -405,6 +407,8 @@ def _on_data_received(self, ep, res, num_bytes):
405
407
if res == 0 and num_bytes > 0 :
406
408
# Process the received data
407
409
self ._process_container (self ._rx_packet [:num_bytes ])
410
+ else :
411
+ print ("_on_data_received" , res , num_bytes )
408
412
409
413
# Submit a new transfer
410
414
self ._submit_out_transfer ()
@@ -443,6 +447,7 @@ def _process_container(self, data):
443
447
data: Container data
444
448
"""
445
449
if len (data ) < 12 :
450
+ print (f"MTP: Invalid container { data } " )
446
451
return # Invalid container
447
452
448
453
# Parse container header using uctypes
@@ -457,6 +462,8 @@ def _process_container(self, data):
457
462
container_type = container .type
458
463
code = container .code
459
464
transaction_id = container .transaction_id
465
+
466
+ print (f"_process_container({ container_type } , { length } , { code } , { transaction_id } " )
460
467
461
468
# Handle by container type
462
469
if container_type == MTP_CONTAINER_TYPE_COMMAND :
0 commit comments