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

    Restart code when micropython throws error

    Scheduled Pinned Locked Moved Software Tools
    other
    4 Posts 4 Posters 1.6k Views 4 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.
    • A Offline
      AptusMarvin
      last edited by

      Hi,

      We have a device running on the field that uses the pysense board.
      Sometimes the python code on the device crashes with the error "Pysense board not detected". When reset the device it works fine again. Now in the field I can't do this. So when this happens it just stops executing any code. Is there a possibility to just restart a python program when it crashes with a random error? (like you have restart=always on systemd on linux for example?)

      Thanks,
      Marvin

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

        @aptusmarvin There is the machine.reset() method, which works like pushing the reset button. If you can detect the crash state by software, for instance if it throws an python exception, then you can call this.

        1 Reply Last reply Reply Quote 0
        • L Offline
          livius @AptusMarvin
          last edited by

          @aptusmarvin
          you can use also watchdog
          https://docs.pycom.io/chapter/firmwareapi/pycom/machine/WDT.html

          think about people first, then computers

          1 Reply Last reply Reply Quote 1
          • S Offline
            stefan85e
            last edited by stefan85e

            This post is deleted!
            1 Reply Last reply Reply Quote 0

            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