isue when using new FTPlib module

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
katesfb
Posts: 22
Joined: Sun Dec 18, 2016 8:09 pm

isue when using new FTPlib module

Post by katesfb » Tue Apr 10, 2018 5:38 am

Hi,
I am trying out the port of FTPlib to micropython and i seem to have a bit of an issue. I am using a pyboard with a wifi skin and have successfully connected to the local WIFI. I then made use of the following example code from the ftplib.py file:

Code: Select all

from ftplib import FTP
ftp = FTP('ftp.python.org')      # connect to host, default port
ftp.login()                               # default, i.e.: user anonymous, passwd anonymous@
ftp.retrlines('LIST')                # list directory contents
ftp.quit()
However i get the following error related to the 'ftp = FTP('ftp.python.org') ' line:

Code: Select all

Traceback (most recent call last):
  File "main.py", line 100, in <module>
  File "ftplib.py", line 206, in __init__
  File "ftplib.py", line 264, in connect
  File "ftplib.py", line 226, in _create_connection
  File "ftplib.py", line 107, in _resolve_addr
TypeError: function takes 2 positional arguments but 3 were given
MicroPython v1.9.2 on 2017-08-23; PYBv1.1 with STM32F405RG
Type "help()" for more information.

Any ideas what could have gone wrong here - i had a look at the _resolve_addr function but i dont know what i have done wrong.

Any help is much appreciated.

Cheers.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: isue when using new FTPlib module

Post by pythoncoder » Thu Apr 12, 2018 7:09 am

It would help if you told us more. A WiFi skin for the Pyboard? Sounds great, but I never knew such a thing existed. I assume you've tested this thoroughly before attempting FTP. A pointer to the board and any support code you're using would help.

Also please give a pointer to the ftplib you're using - there is no working code in micropython-lib.
Peter Hinch
Index to my micropython libraries.

katesfb
Posts: 22
Joined: Sun Dec 18, 2016 8:09 pm

Re: isue when using new FTPlib module

Post by katesfb » Sun Apr 22, 2018 11:19 pm

Hi,
And thanks for the reply, much appreciated.

The link to the pyboard wifi skin is here https://www.tinyosshop.com/wifi-skin-fo ... er_name=py

This page also has some test code and library. Code seems to work in that i can connect the local wifi network with it. Thats all i have successfully done so far.

The ftplib i am using is here https://github.com/SpotlightKid/micropy ... /ftplib.py

My code and the associated error is below:

Code: Select all

from pyb import Pin
from ftplib import FTP
import pywifi

print('Hardware reset for TONYLABS PyWifi')
print('=============================================')
rst = Pin('X12', Pin.OUT)
rst.low()
pyb.delay(20)
rst.high()
pyb.delay(500)

esp = pywifi.ESP8266(1, 115200)

print('Testing generic methods')
print('=======================')
print('AT startup...')
if esp.test():
    print('Success!')
    pyb.LED(1).on() #GREEN LED ON
else:
    print('Failed!')

'''
print('Soft-Reset...')
if esp.reset():
    print('Success!')
else:
    print('Failed!')
'''

print('Another AT startup...')
if esp.test():
    print('Success!')
else:
    print('Failed!')


print('Check ESP8266 firmware version')
print('==============================')
esp.version()


print('Testing WIFI methods')
print('====================')
'''
1: station mode
2: accesspoint mode
3: accesspoint and station mode
'''

wifi_mode = 1
print("Testing get_mode/set_mode of value '%s'(%i)..." % (pywifi.WIFI_MODES[wifi_mode], wifi_mode))
esp.set_mode(wifi_mode)

if esp.get_mode() == wifi_mode:
    print('Success!')
else:
    print('Failed!')

pyb.delay(100)

print('Connecting to network')
print('==============================')
esp.connect(ssid='Taihoro', psk='Innxxxxxxx')

pyb.delay(20)

print(esp.get_station_ip())

pyb.LED(1).off() #GREEN LED ON
pyb.LED(4).on() #BLUE LED ON

print('Connecting to an FTP network')
print('==============================')

ftp = FTP('ftp.python.org')      # connect to host, default port
ftp.login()                      # default, i.e.: user anonymous, passwd anonymous@
ftp.retrlines('LIST')            # list directory contents
ftp.quit()

Code: Select all

Traceback (most recent call last):
  File "main.py", line 100, in <module>
  File "ftplib.py", line 206, in __init__
  File "ftplib.py", line 264, in connect
  File "ftplib.py", line 226, in _create_connection
  File "ftplib.py", line 107, in _resolve_addr
TypeError: function takes 2 positional arguments but 3 were given
MicroPython v1.9.2 on 2017-08-23; PYBv1.1 with STM32F405RG
Type "help()" for more information.

Any help is much appreciated.

Cheers.

katesfb
Posts: 22
Joined: Sun Dec 18, 2016 8:09 pm

Re: isue when using new FTPlib module

Post by katesfb » Mon Apr 30, 2018 3:04 am

Anybody have any ideas on this.

Any help is much appreciated.

Cheers

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: isue when using new FTPlib module

Post by Roberthh » Mon Apr 30, 2018 5:59 am

What I see is an ordinary ESP8266 with AT firmware connected to a serial port of the PyBoard. What I do not see is any link into the Network stack of Micropython. Unless that is given, you cannot use the standard socket interface.

Post Reply