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

    Watchdog timer question

    Scheduled Pinned Locked Moved Discussion
    3 Posts 2 Posters 317 Views 2 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.
    • S Offline
      SiMoS-IoT
      last edited by

      Can someone explain the correct use of the watchdog timer...

      I have various combinations of SiPy or FiPy on Pysense or Expansion Board 3.1's all with the latest firmware as of today.

      The code is simply reading sensors and sending data to Adafruit.io via wifi, sigfox or lte. Occasionally the code would hang (typically 1 per 200 cycles or thereabouts)...not sure where as they were running on batteries so not connected to the REPL.

      I added a WDT to the code (single thread) and set it at 3 x the cycle time of the code...still had hangs (still 1 per 200 cycles or thereabouts). I've now put a separate pseudoWDT on some of the Pysense combinations again set a 3 x the cycle time of the code, but this time in a separate thread to the main code and the WDT..so far (24 hours) no hangs...so this raises the question, should the WDT be on a it's own thread.

      1 Reply Last reply Reply Quote 0
      • M Offline
        misterlisty
        last edited by

        Just create a timer alarm that feeds the watchdog..if you program hangs it will reboot.

        class WD:
        def init(self):
        self.seconds = 0
        self.__alarm = Timer.Alarm(self._seconds_handler, 3, periodic=True)
        def _seconds_handler(self, alarm):
        wdt.feed()

        1 Reply Last reply Reply Quote 0
        • S Offline
          SiMoS-IoT
          last edited by

          Doesn't feeding the watchdog simply delay the reset? That doesn't help my situation.

          I already have a watchdog timer in the code and when it hung, the watchdog didn't activate so I'm not sure if the watchdog hung because it was in the same thread as the code or if WDT class runs in a separate thread by design which implies a bigger problem with the WDT in general.

          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