Call method and passed as a parameter

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.
User avatar
pythoncoder
Posts: 3724
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Call method and passed as a parameter

Post by pythoncoder » Mon Jun 17, 2019 8:53 am

jimmo wrote:
Sun Jun 16, 2019 5:47 pm
...
When you past code into the forum, select it and then press the </> button so the formatting is preserved.
When someone omits to do this (or can't because they are a new forum user) you can see the formatting by pressing the quote button. A tip someone gave me a while ago.
Peter Hinch

User avatar
jimmo
Posts: 892
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Call method and passed as a parameter

Post by jimmo » Mon Jun 17, 2019 9:33 am

giants wrote:
Mon Jun 17, 2019 6:10 am
I use UPyCraftv1.1 do you use other software ? really i don't understand
Sergio
It does kind of look like it's not actually updating the code on the board. Like why is it complaining about line 15?

Can you paste in the exact code you're using? Like what is the exact contents of main.py? Are there other files? Does the error happen when you program it or are you running the commands on the REPL?

Sorry I don't know anything about upycraft...

Other options depends which board you're using? On pyboard I use pyboard.py or by accessing the filesystem directly. On ESP8266/ESP32 I use ampy or rshell (or quite often, webrepl).

Sorry I hope I'm not missing something obvious but I can't see anything wrong, hopefully someone else can spot the problem! (I've actually tried running your code on a pyboard and it seems fine?)
pythoncoder wrote:
Mon Jun 17, 2019 8:53 am
When someone omits to do this (or can't because they are a new forum user) you can see the formatting by pressing the quote button. A tip someone gave me a while ago.
Good tip! Thank you :)

giants
Posts: 19
Joined: Fri Apr 26, 2019 2:07 pm

Re: Call method and passed as a parameter

Post by giants » Mon Jun 17, 2019 5:52 pm

Code: Select all

from machine import Pin, I2C
import RFD77402

from time import sleep


dist = rfd77 (I2C(-1, scl=Pin(5), sda=Pin(4), freq=400000))
dist.scan()
that is what i wrote in main.py.

and this is the board

Image
Attachments
81xBVFRZ7UL._SX466_.jpg
81xBVFRZ7UL._SX466_.jpg (33.58 KiB) Viewed 411 times

giants
Posts: 19
Joined: Fri Apr 26, 2019 2:07 pm

Re: Call method and passed as a parameter

Post by giants » Mon Jun 17, 2019 5:53 pm

thank you

User avatar
jimmo
Posts: 892
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Call method and passed as a parameter

Post by jimmo » Mon Jun 17, 2019 10:08 pm

giants wrote:
Mon Jun 17, 2019 5:52 pm

Code: Select all

from machine import Pin, I2C
import RFD77402

from time import sleep


dist = rfd77 (I2C(-1, scl=Pin(5), sda=Pin(4), freq=400000))
dist.scan()
that is what i wrote in main.py.
This can't work - rfd77 shouldn't be available when you import like that. (you would have to write "dist = RFD77402.rfd77(...)". My guess is that you somehow have previously written a definition for rfd77 that is still in scope, and it's using that one instead.

I think pycraft is confusing you here with the way it sometimes copies files and sometimes executes them directly.

Does pycraft provide a way to list files on the device or clear the filesystem? Try and clear everything and start from scratch.

If not, you can do this with the REPL

Code: Select all

>>> import os
>>> os.listdir()
.. names of files
>>> os.unlink("foo")
then reset and start again

giants
Posts: 19
Joined: Fri Apr 26, 2019 2:07 pm

Re: Call method and passed as a parameter

Post by giants » Wed Jun 19, 2019 10:29 am

Hi
finally work , be honest with you i change side and i download the new firmware for the ESP8266.
Thank you for your patience. For sure i need your help in the future :D :D :D :D

Sergio

User avatar
jimmo
Posts: 892
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Call method and passed as a parameter

Post by jimmo » Wed Jun 19, 2019 10:58 am

Glad it's working! This is one disadvantage of the ESP8266/ESP32 boards compared to the STM32 boards that support the USB filesystem. It's a lot less simple to interact with the actual files on the board.

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

Re: Call method and passed as a parameter

Post by Roberthh » Wed Jun 19, 2019 11:16 am

If you have scripts on the STM32 systems that create or modify files, the USB file support is a nightmare. I hade several cases of corrupted files systems. So I always switch it off. For file exchange with the ESP devices I use ftp. Filezilla as client is pretty convenient, not much different from the host file manager.

giants
Posts: 19
Joined: Fri Apr 26, 2019 2:07 pm

Re: Call method and passed as a parameter

Post by giants » Wed Jun 19, 2019 12:46 pm

Thank you. I think mabye is good for me start to "play" with python for have more confidence and second step ESP or other boards.

Have a good day
Sergio

Post Reply