Forum Rule: Always post complete source code & details to reproduce any issue!
Page 26 of 26 FirstFirst ... 16 24 25 26
Results 626 to 633 of 633

Thread: MTP Responder Contribution

  1. #626
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,111
    Quote Originally Posted by KurtE View Post
    Morning - Right now playing in the branch: MEM_send_object_large
    Ok will stop playing on this end. I did put a T4.1 with 8Mb PSRAM but the 512, 1G, and 2G files failed to transfer any of the PDF files and essentially disconnected the flash drives from windows to where I had to power cycle.

  2. #627
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,201
    Quote Originally Posted by mjs513 View Post
    Ok will stop playing on this end. I did put a T4.1 with 8Mb PSRAM but the 512, 1G, and 2G files failed to transfer any of the PDF files and essentially disconnected the flash drives from windows to where I had to power cycle.
    Totally understand.... Pretty frustrating.

    This morning I decided to waste some time and see if going at this completely wrong. So tried a KISS version of the code...
    Code:
        bool MTPD::SendObject() {
          bool return_value = false;
          uint8_t print_count = 0;
          pull_packet(rx_data_buffer);
          read(0,0);
          uint32_t len = ReadMTPHeader();
          uint32_t index = sizeof(MTPHeader);  
          printf("MTPD::SendObject: len:%u\n", len);
          elapsedMicros em_total = 0;
          uint32_t cb_write = MTP_RX_SIZE - index;                     // how many data in usb-packet
    
          if (cb_write > len) cb_write = len;
          if(!storage_->write((char*)rx_data_buffer + index, cb_write)) goto abort;
          len -= cb_write;
          cb_write = MTP_RX_SIZE;
          while (len) 
          { 
            printf(".");
            if (!(++print_count & 0x3f)) printf("\n");
    
            // Build in timeout... 
            uint32_t elapsed_before_packet = em_total;
            elapsedMillis em_packet = 0;
            while(!usb_mtp_available())
            {
              if (em_packet > 1000)
              {
                printf("\nTimeout: %u\n", elapsed_before_packet);
                goto abort;
              }
            }
            usb_mtp_recv(rx_data_buffer, 60);
            if (cb_write > len) cb_write = len;
            if(!storage_->write((char*)rx_data_buffer, cb_write)) goto abort;
            len -= cb_write;
          }
          return_value = true;
          printf("$");
        abort:      
          storage_->close();
          printf(">> %u\n", (uint32_t)em_total);
          return return_value;
        }
    Tried doing some send objects to my problematic QSPI ...

    First tried a simple smaller file:
    Code:
    CMD: 100d(SEND_OBJECT)l: 12 T:71
    MTPD::SendObject: len:44082
    ................................................................
    ......................$>> 539871
    RESP:2001(RSP:OK)l: 12 T:71
    Which worked...

    Then tried a larger file
    Code:
    CMD: 100d(SEND_OBJECT)l: 12 T:7f
    MTPD::SendObject: len:340510
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ............................................
    Timeout: 3024631
    >> 4077542
    RESP:2005(RSP:OPERATION_NOT_SUPPORTED)l: 12 T:7f
    Which failed...
    Note: it stopped receiving USB packets a little after 3 seconds.

    I reset and tried again with a larger file:
    Code:
    CMD: 100d(SEND_OBJECT)l: 12 T:7a
    MTPD::SendObject: len:3161263
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ....................
    Timeout: 3033143
    >> 4034826
    RESP:2005(RSP:OPERATION_NOT_SUPPORTED)l: 12 T:7a
    Again it stopped receiving USB packets a little over 3 seconds. Was sort of curious if the Timeout on the PC might change proportionately depending on size... In this case it does not appear to.

    Now back to the other drawing board!

  3. #628
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,111
    Morning @KurtE
    Know what you mean. Last night was playing your send_object_large branch and playing around with buffer sizes. Unfortunately couldn't get it to work with NANDs for large files. Transfers would time out when file was almost completely transfered then would have to reset the T4.x. This was using both SPI and QSPI. For the NOR chips seemed to work ok except for the 25Q16jv one (the one on the audio board). To be honest for me your old send_object branch was working better with the NANDs except for the one PDF file I had.

  4. #629
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,201
    The interesting thing is I tried the simple version that crashed after 3 plus seconds to Flash to go instead to SDIO. Again 512 bytes at a time.
    Code:
    CMD: 100c(SEND_OBJECT_INFO)l: 20 T:299 : 1 ffffffff
    DATA:100c(SEND_OBJECT_INFO)l: 166 T:299 : 0 3000 3130d7 3000 0
    SendObjectInfo: 1 4294967295 20003480: 0 3000 0 3130d7 3000 0 0 0 c00 900 18 0 0 0 0 : DSC03361.JPG
    RESP:2001(RSP:OK)l: 24 T:299 : 1 ffffffff 52
    CMD: 100d(SEND_OBJECT)l: 12 T:29a
    MTPD::SendObject: len:3223767
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    .........................................................#.......
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    #................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ...............#.................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ...........................................#.....................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    .............................................#...................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    .#...............................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ..................................................#..............
    ................................................................
    ................................................................
    ................................................................
    .................................................#...............
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ............................................#....................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ................................................................
    ........................................................#........
    ................................................................
    ........................$>> 10296997
    RESP:2001(RSP:OK)l: 12 T:29a
    And it took over 10 seconds to send the file.... So again it appears to be some form of pacing issue...
    Note: the #'s, I was curious, so every 1 second I sent an event back to host:
    send_Event(MTP_EVENT_UNREPORTED_STATUS); //

    Did not help in the QSPI version. but left it in in this run... So as you mentioned the version of code I had earlier that read at a certain pace appeared to help. I have most of the same code in place now, but maybe pacing is different. So again more experiments...

    I was running into another issue when I tried it with RAM drive, but figured out I was running out of space.

    The SendObjectInfo code is not checking to see if there is enough storage space available, to error it out if not...
    Probably should have it call the File systems totalSize and subtract the usedSize and have it error out with either OBJECT_too_large or Store full...

  5. #630
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    279
    I've had this new MTP code working for a few weeks now. Such a fantastic upgrade!

    I'm curious, though...is there a way that the Teensy knows that the PC is connected via USB? Is there a call to the MTP library or to the underlying Teensy USB infrastructure that I can use to see if anything is connected? I might like to light up an LED or something to give visual indication that the PC is connected.

    Sorry if the answer is obvious...I'm super new to this.

    Chip

  6. #631
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,999
    Quote Originally Posted by chipaudette View Post
    I've had this new MTP code working for a few weeks now. Such a fantastic upgrade!

    I'm curious, though...is there a way that the Teensy knows that the PC is connected via USB? Is there a call to the MTP library or to the underlying Teensy USB infrastructure that I can use to see if anything is connected? I might like to light up an LED or something to give visual indication that the PC is connected.

    Sorry if the answer is obvious...I'm super new to this.

    Chip
    In MTP I'm using
    Code:
    extern volatile uint8_t usb_configuration;
    to know if usb is configured (taken from other devices)
    it is 0 when not initialized

  7. #632
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,201
    I was wondering if we should build that capability into the mtp object?


    That is do like we do in the USB Host cases or the !Serial type cases...

    That is maybe add a member to MTPD:

    Sort of like at the beginning:
    Code:
    public:
    
      explicit MTPD(MTPStorageInterface* storage): storage_(storage) {}
      operator bool() { return usb_configuration;}
    You can probably do it that way, or you could have it look at some state variable you set (or could set) at either configure time or by processing messages.

    Example you could probably trigger off of if we have opened a session: bool could be something like return sessionID_
    Currently local variable in the .cpp file should probably be moved to be static member of the MTPD_ class...

  8. #633
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,999
    Quote Originally Posted by KurtE View Post
    I was wondering if we should build that capability into the mtp object?


    That is do like we do in the USB Host cases or the !Serial type cases...

    That is maybe add a member to MTPD:

    Sort of like at the beginning:
    Code:
    public:
    
      explicit MTPD(MTPStorageInterface* storage): storage_(storage) {}
      operator bool() { return usb_configuration;}
    This is partially done in Serial, but I agree that checking for open session is a good idea, especially as PC will time out MTP when session is not established for some time (have not established timeout value, but encountered PC timeout few times)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •