Giter Club home page Giter Club logo

Comments (13)

SpotlightKid avatar SpotlightKid commented on May 28, 2024 1

You can just connect to the ESP board before the test and establish the connection manually, then leave the REPL without resetting the board. The connection will stay up as long as you don't reset the board.

The way I do it, I have this module (or a similar version) copied to the board and also a simple JSON configuration file for it in the format show below. Then I just use from netconfig import connect; connect('netconfig.json') to fire up the connection. You can put that line in boot.py or, run it manually via the REPL or just insert that line at the top of test/esp/test_ftplib.py.

{
    "ssid": "My WLAN",
    "password": "XXXXXXXX",
    "timeout": 8
}

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

The code in the current master branch was never tested with the esp32 port. If it works at all, you should use the version of ftplib.py in the esp8266 directory.

You can also try the new version (with provisional TLS support) in the feature/ftp-over-tls branch.

Here's how I tested this successfully on an ESP32-WROOM dev board:

First shell session (needs pyftpdlib Python package installed):

cd test
./pyftpdlib-server.py -p 2121

Second shell session (connect ESP32 board via USB):

for py in ftplib ftplibtls ftpadvanced; do
    mpy-cross esp/${py}.py
    rshell -p /dev/ttyUSB0 cp esp/${py}.mpy /pyboard
done

cd test
# assumes WiFi connection is already established
pyboard --device /dev/ttyUSB0 esp/test_ftplib.py

from micropython-ftplib.

valenzmanu avatar valenzmanu commented on May 28, 2024

Thanks for your response.

I tried using ftplib.py file in the esp8266 directory but got the error below. I assume this version won't be compatible with my board.

Traceback (most recent call last):
  File "<stdin>", line 44, in <module>
  File "ftplib.py", line 220, in connect
  File "ftplib.py", line 89, in __getattr__
AttributeError: 'socket' object has no attribute 'makefile'

I'll try the new version. Just a question, where should I put the wifi connection code? should I add it to the test_ftplib.py file or boot.py?

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

@valenzmanu: How did the feature/ftp-over-tls branch work out for you?

from micropython-ftplib.

valenzmanu avatar valenzmanu commented on May 28, 2024

@SpotlightKid sorry for the delay. I tried the feature/ftp-over-tls branch, but got this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test_ftplib.py", line 5, in <module>
  File "ftplib.py", line 160, in __init__
  File "ftplib.py", line 220, in connect
  File "ftplib.py", line 89, in __getattr__
AttributeError: 'socket' object has no attribute 'makefile'

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

You seem to have an older version of micropython on your ESP32. In newer versions,, usocket.socket object should have a makefile method:

https://github.com/micropython/micropython/blob/13ad1a4f06f2d114c821279f58fa7462e8bd0d41/ports/esp32/modsocket.c#L759

Are you able to try with a newer firmware version? Preferably a daily build from here:

https://www.micropython.org/download/esp32/

Nevertheless, I should add a workaround for a missing makefile method like I did in other places of the file. I think the ESP8266 port still needs that. These inconsistencies between the ports can get quite annoying sometimes.

from micropython-ftplib.

valenzmanu avatar valenzmanu commented on May 28, 2024

Since I'm using this board and not a standalone ESP32, I don't think I can use that build (but not sure). I'm using the v0.5.0 of this micropython port

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

I just pushed a small fix that should allow esp/ftplib.py to be used with firmware versions where socket.socket.makefile is not supported.

Obviously I can't test this on your custom board / firmware, so please try it out and let me know, if that works for you.

from micropython-ftplib.

valenzmanu avatar valenzmanu commented on May 28, 2024

Thanks!

I was able to login:

./pyftpdlib-server.py -p 2121
[I 2020-06-25 14:56:22] concurrency model: async
[I 2020-06-25 14:56:22] masquerade (NAT) address: None
[I 2020-06-25 14:56:22] passive ports: None
[I 2020-06-25 14:56:22] >>> starting FTP server on 0.0.0.0:2121, pid=2963 <<<
[I 2020-06-25 14:56:49] 192.168.0.138:56442-[] FTP session opened (connect)
[I 2020-06-25 14:56:53] 192.168.0.138:56442-[joedoe] USER 'joedoe' logged in.

However, I got an error in this line files = ftp.nlst() when executing test_ftplib.py :

File "ftpadvanced.py", line 18, in nlst
  File "ftplib.py", line 506, in retrlines
  File "ftplib.py", line 434, in ntransfercmd
  File "ftplib.py", line 420, in ntransfercmd
  File "ftplib.py", line 292, in sendcmd
  File "ftplib.py", line 257, in getresp
  File "ftplib.py", line 243, in getmultiline
  File "ftplib.py", line 235, in getline
EOFError: 
MicroPython v0.5.0-95-g05c4e70 on 2020-06-05; Sipeed_M1 with kendryte-k210
Type "help()" for more information.
>>> 

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

This indicates that the connection was closed while the client waited for a response to the NLST command. Though it is curious that the server output does not show anything about this. It's hard to say what caused this. I'm a unsure now how to help you further without access to the same firmware or board as you're using.

from micropython-ftplib.

valenzmanu avatar valenzmanu commented on May 28, 2024

I see, I'll try to debug it. Ultimately what I need is just to upload a .jpg file, I don't really need the ability to list all the files in the FTP server. I would like to try to upload a file, if it works, would be more than enough for my application.

I saw the test_upload.py and ftpupload.py files outside the esp directory. How can I upload a file using a simple FTP connection? (Not over TLS), should I use the upload function?

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

should I use the upload function?

Yes. Just make sure that you install / import the right ftplib.py version.

from micropython-ftplib.

SpotlightKid avatar SpotlightKid commented on May 28, 2024

Closing this due to no further feedback. Please feel free to re-open the issue if you have more information.

from micropython-ftplib.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.