Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    MicropyGPS: Failed to write file

    Scheduled Pinned Locked Moved LoPy
    lopymicropythonfrozen modulesmicropygps
    16 Posts 3 Posters 1.8k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Paloma @crumble
      last edited by

      @crumble I received my LoPy4s and now I have a different, but similar error.

      The first upload worked fine and I was able to load all files through pymakr. I changed some code and tried to upload again and I got the following:

      [1/1] Writing file to main.py (9kb)
      Failed to write file, trying again...
      Failed to write file, trying again...
      Failed to write file: incorrect padding
      Upload done, resetting board

      Then it seems like the file has been uploaded, but I get errors in weird places that shouldn't be giving me errors. Code that didn't change at all from the first import like this line:

      bme = bme280.BME280(i2c = i2c)

      triggers this error:

      AttributeError: 'module' object has no attribute 'BME280'

      And this line:

      print("BME280 initialized...")

      gives me the error:

      SyntaxError: invalid syntax.

      Please note that these errors occur after trying to upload the same file, so it's triggering different nonsensical errors.

      I did some searching around and a few people said this could also be a memory issue, but I'm just stunned that my 5 relatively simple files are causing this huge of an error. Any ideas?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Paloma
        last edited by

        @paloma Try using simple robust tools like ftp (Filezilla) for file upload and putty or telnet for the terminal. The Pymakr suite, even if it may be convenient, adds another level of complexity and problems.

        P 1 Reply Last reply Reply Quote 1
        • P Offline
          Paloma @robert-hh
          last edited by

          @robert-hh Thanks for getting back to me! I'm very new to micropython and ubuntu, so this has been a learning experience for sure!

          I'm working on trying to connect to the Lopy using FTP, but so far I can't connect to the board. I tried using the default FTP client in a terminal, but I get the error, "connect: Connection timed out."

          When I try to connect through Filezilla, I get the same issue. "Connection timed out after 20 seconds of inactivity"
          My settings are as follows:

          in the site manager:

          General Tab:
          Host: 192.168.4.1 (I verified in Atom that this is the correct address)
          Protocol: FTP
          Encryption: plain FTP (insecure)
          user: micro
          password:python

          Transfer Settings Tab:
          Transfer mode: Passive
          Maximum number of connections: 1

          Any ideas what else I need to change?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @Paloma
            last edited by

            @paloma To access via FTP, you have to be on the same network. I do not know how your PC if configured, but most likely not for 192.168.4.x. If you want to use LoPy in your home network, then it is better to operate it in STA mode and let it connect to you local access point. Follow the instructions here under the heading: Connection to a Router . https://docs.pycom.io/tutorials-and-examples/all/wlan. If you know your SSID, you can simplify that to:

            from network import WLAN
            wlan = WLAN(mode=WLAN.STA)
            wlan.connect('my_ssid', auth=(network.WLAN.WPA2, 'mywifikey'), timeout=5000)
            while not wlan.isconnected():
                machine.idle() # save power while waiting
            print('WLAN connection succeeded!')
            print('network config:', wlan.ifconfig())
            

            The last line will tell you the IP address of your device, which you then can use to connect with ftp and/or telnet.

            P 1 Reply Last reply Reply Quote 1
            • P Offline
              Paloma @robert-hh
              last edited by

              @robert-hh It took me a little while to get this up and running because I had to switch to my laptop (desktop only has a wired connection to a different network). I connected my Lopy4 to the same wireless network as my laptop and ran the program and received an IP (yay!). I printed wlan.ifconfig() and received 4 addresses. I then looked at the page you linked and determined that the first item would be the IP address. Unfortunately when I use filezilla with this new IP address I get the same problems (boo!). Not sure where to go from here.

              robert-hhR C 2 Replies Last reply Reply Quote 1
              • robert-hhR Offline
                robert-hh @Paloma
                last edited by robert-hh

                @paloma You may start with command line ftp, which avoids the setting djungle of Filezilla. Just run:
                ftp -p <your_ip_address>
                It should ask you for name (micro) and password (python).
                then you can:
                cd /flash
                ls

                1 Reply Last reply Reply Quote 1
                • C Offline
                  crumble @Paloma
                  last edited by

                  @Paloma

                  Check if you can reach another FTP server. If not, ask your admins to open the firewall for FTP (whole range).

                  Your client must be in pasive mode and shall allow only 1 connection.

                  Search mode of the docu is f* up :(
                  finds the sentence, displays the extract, but link does not work. How can one shout RTFM, if the FM doesn't work? Wait. Print the doc and read it carefully ;) pycom mentioned somewhere how to configure your FTP client.

                  1 Reply Last reply Reply Quote 1
                  • P Offline
                    Paloma
                    last edited by

                    @robert-hh I had to move to a windows machine, so I'm using the command prompt and I get the same output as before. Connection timed out.

                    @crumble I'm not sure how to check if I can reach another FTP server. I'll try to look into firewall issues to see what I can figure out.

                    robert-hhR 1 Reply Last reply Reply Quote 1
                    • robert-hhR Offline
                      robert-hh @Paloma
                      last edited by

                      @paloma The windows command line ftp will not work with the Lopy, since it does not support passive mode. But you should at öeast be able to connect. Only commands like ls or all file transfers will not work.
                      As @crumble said, there may be a problem with the network settings in the router.
                      The link for setting FileZilla is here: https://docs.pycom.io/getting-started/programming/ftp

                      P 1 Reply Last reply Reply Quote 1
                      • P Offline
                        Paloma @robert-hh
                        last edited by

                        @robert-hh I had to move everything to a completely different network, but it works now! My set up is a little clumsy, but I'm able to develop new code again. Thank you and @crumble so much for your help!!

                        Right now what I'm doing is connecting to WiFi via the atom repl and then opening filezilla. I then use FTP to transfer the new files over and manually restart the board to run the new main.py. It's a little clumsy having to switch back and forth and reconnect to WiFi on each go, but I can probably add the WiFi code to the main.py that I'm working from so that it doesn't lose connection on reboot.

                        I learned a ton about micropython and the lopy through having this problem, so I'm not miffed about having to deal with it.

                        robert-hhR 1 Reply Last reply Reply Quote 1
                        • robert-hhR Offline
                          robert-hh @Paloma
                          last edited by

                          @paloma You can configure Filezilla in a way, that double-click on a file in the LoPy pane will open that file in your Favorite editor. Storing that file will transfer it back to the LoPy. For REPL, you might also use other tools like screen, picocom, putty, .., which support VT100 code sequences, in case you need them.

                          1 Reply Last reply Reply Quote 1

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom