Page 2 of 2

Re: Call method and passed as a parameter

Posted: Mon Jun 17, 2019 8:53 am
by pythoncoder
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.

Re: Call method and passed as a parameter

Posted: Mon Jun 17, 2019 9:33 am
by jimmo
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 :)

Re: Call method and passed as a parameter

Posted: Mon Jun 17, 2019 5:52 pm
by giants

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

Re: Call method and passed as a parameter

Posted: Mon Jun 17, 2019 5:53 pm
by giants
thank you

Re: Call method and passed as a parameter

Posted: Mon Jun 17, 2019 10:08 pm
by jimmo
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

Re: Call method and passed as a parameter

Posted: Wed Jun 19, 2019 10:29 am
by giants
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

Re: Call method and passed as a parameter

Posted: Wed Jun 19, 2019 10:58 am
by jimmo
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.

Re: Call method and passed as a parameter

Posted: Wed Jun 19, 2019 11:16 am
by Roberthh
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.

Re: Call method and passed as a parameter

Posted: Wed Jun 19, 2019 12:46 pm
by giants
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