@@ -380,6 +380,7 @@ def on_reset(self):
380380
381381 def on_open (self ):
382382 """Handle USB configuration event."""
383+ super ().on_open ()
383384 # Submit initial OUT transfer to receive commands
384385 self ._submit_out_transfer ()
385386
@@ -389,9 +390,10 @@ def is_open(self):
389390
390391 def _submit_out_transfer (self ):
391392 """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 ):
393394 return
394395
396+ print ("submit_xfer" )
395397 self .submit_xfer (self ._bulk_out_ep , self ._rx_packet , self ._on_data_received )
396398
397399 def _on_data_received (self , ep , res , num_bytes ):
@@ -405,6 +407,8 @@ def _on_data_received(self, ep, res, num_bytes):
405407 if res == 0 and num_bytes > 0 :
406408 # Process the received data
407409 self ._process_container (self ._rx_packet [:num_bytes ])
410+ else :
411+ print ("_on_data_received" , res , num_bytes )
408412
409413 # Submit a new transfer
410414 self ._submit_out_transfer ()
@@ -443,6 +447,7 @@ def _process_container(self, data):
443447 data: Container data
444448 """
445449 if len (data ) < 12 :
450+ print (f"MTP: Invalid container { data } " )
446451 return # Invalid container
447452
448453 # Parse container header using uctypes
@@ -457,6 +462,8 @@ def _process_container(self, data):
457462 container_type = container .type
458463 code = container .code
459464 transaction_id = container .transaction_id
465+
466+ print (f"_process_container({ container_type } , { length } , { code } , { transaction_id } " )
460467
461468 # Handle by container type
462469 if container_type == MTP_CONTAINER_TYPE_COMMAND :
0 commit comments