Forum Rule: Always post complete source code & details to reproduce any issue!
Page 6 of 6 FirstFirst ... 4 5 6
Results 126 to 131 of 131

Thread: Teensy 4.1 - Adafruit Airlift Featherwing Co-Processor FTP Server not opening Port 21

  1. #126
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    687
    @mjs513 - Decided to check out this version of FTPServer using QNEthernet on the the T4.1:
    https://github.com/khoih-prog/FTP_Server_Teensy41

    It works in passive mode but still has file transfer problems that we are seeing.
    Code:
    Status:	Connecting to 192.168.0.110:21...
    Status:	Connection established, waiting for welcome message...
    Response:	220--- Welcome to FTP_Server_Teensy41 ---
    Response:	220 -- FTP_Server_Teensy41 v1.0.0 --
    Status:	Plain FTP is insecure. Please switch to FTP over TLS.
    Command:	USER teensy4x
    Response:	331 Ok. Password required
    Command:	PASS ********
    Response:	230 Ok
    Status:	Server does not support non-ASCII characters.
    Status:	Logged in
    Trace:	Measured latency of 248 ms
    Status:	Retrieving directory listing...
    Command:	PWD
    Response:	257 "/" is your current directory
    Status:	Directory listing of "/" successful
    Status:	Disconnected from server
    Status:	Connecting to 192.168.0.110:21...
    Status:	Connection established, waiting for welcome message...
    Error:	Connection timed out after 20 seconds of inactivity
    Error:	Could not connect to server
    Status:	Disconnected from server
    Status:	Delaying connection for 5 seconds due to previously failed connection attempt...
    Status:	Connecting to 192.168.0.110:21...
    Status:	Connection established, waiting for welcome message...
    The section marked in red is where I initiated the transfer from the T4.1 to Filezilla. For some reason it disconnects from the Teensy and tries to reconnect to it and hangs waiting for the welcome message. Don't know if this is normal for a file transfer or not. Either way the server is not disconnecting, reconnecting and sending the welcome message. Also you can connect and disconnect from the Teensy without having to reset the Teensy.

    Got to take walk away from this for a while and checkout whats going on with USBHost_t36

  2. #127
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    687
    @mjs513, @Khoih-prog - Was working with FTP_Server_Teensy41 today to try and figure out why I was only getting partial transfers when downloading from the T4.1 to the PC using gFTP or Filezilla. Turns out the failure was in the doRetrieve() function:
    Code:
    bool FtpServer::doRetrieve()
    {
      if ( ! dataConnected())
      {
        file.close();
    
        return false;
      }
    
      int16_t nb = file.read( buf, FTP_BUF_SIZE );
    
      if ( nb > 0 )
      {
        data.write( buf, nb );
        bytesTransfered += nb;
        return true;
      }
    
      closeTransfer();
    
      return false;
    }
    The data.write() buffer was being overwritten before the transfer was complete. That's why the files were coming up smaller on the client side than the original transfer size. I changed the doRetrieve() function to this:
    Code:
    bool FtpServer::doRetrieve()
    {
      if ( ! dataConnected())
      {
        file.close();
        return false;
      }
      // Find available space in data.write() buffer.
      int spaceLeft = data.availableForWrite();
      // Get remaining bytes to read from file.
      int32_t leftToXfer = file.available();
    
      if (spaceLeft <= 0) {
        return true; // Return true if no space available.
      }
    
      // Calculate read size.
      // Base the amount to read on the space available in the
      // data.write() buffer. 
      if(leftToXfer) {
        int32_t nb = file.read( buf,(spaceLeft <= FTP_BUF_SIZE) ? spaceLeft : FTP_BUF_SIZE);
        data.write(buf, nb);
        bytesTransfered += nb;
        return true;
      }
      closeTransfer();
      return false;
    }
    The size of the transfer will always be equal to spaceLeft if it is less than or equal to FTP_BUF_SIZE.
    Tested this with QNEthernet and NativeEthernet. FTP_BUF_SIZE gave the best transfer speeds. ~2MBs.

    @Khoih-prog will issue a PR.

  3. #128
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,117
    @wwatson
    Sorry been distracted with USBMSC stuff. Sounds like you are making progress. Also probably applicable SimpleFTPServer as well. Will have to play again soon with this.

  4. #129
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,316
    Sorry all, keep meaning to try this stuff out...

    But been distracted also with the MSC stuff. More details on that soon.

  5. #130
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    687
    Quote Originally Posted by mjs513 View Post
    @wwatson
    Sorry been distracted with USBMSC stuff. Sounds like you are making progress. Also probably applicable SimpleFTPServer as well. Will have to play again soon with this.
    I have SimpleFTPServer so messed up I will have to start over with it. I think now that I have FTP_Server_Teensy41 working, I'll try to add WiFiNINA to it as a base to work from. It is easier to adapt to and debug. Use it as a control. Then I'll start fresh with SimpleFTPServer.

    I did a little testing with the current state of USBHost_t36. Everything seems to work so far I'm sure you guys are up to your eyebrows with changes. Will watch and test were I can...

    Even tested multiple partitions on a thumb stick. Worked good
    Last edited by wwatson; Today at 12:41 AM. Reason: More Info...

  6. #131
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    116
    Hi @wwatson

    The new FTP_Server_Teensy41 releases v1.1.0 has just been published. Your contribution is noted in Contributions and Thanks

    Best Regards,

    ---

    Releases v1.1.0

    1. Fix bug incomplete downloads from server to client. Check Incomplete downloads from server to client. #2

Posting Permissions

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