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

    `eval` in BLE callback resets board

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0bleeval
    5 Posts 2 Posters 1.4k 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.
    • B Offline
      bm
      last edited by

      I have some code like this:

      def exec_handler(chr):
        try:
          result = eval(command_buffer)
        except Exception as e:
          result = "{}: - {}".format(type(e).__name__, e)
        print("Exec result: '{}'".format(result))
      

      exec_handler is set as the callback for a characteristic write event.

      If I pass it something like 1 + 1 or "hello" * 5 it works fine.

      If I pass it something more complex like list(range(10)) or pycom.rgbled(0xff0000), the board resets.

      If I call the handler directly from the REPL, it works fine in all cases I have tried.

      Any ideas where I'm doing something wrong or if it's a firmware bug?

      (sysname='WiPy', nodename='WiPy', release='1.6.7.b1', version='v1.8.6-493-g99ac80fe on 2017-03-03', machine='WiPy with E SP32')

      1 Reply Last reply Reply Quote 0
      • B Offline
        bm
        last edited by bm

        We just got some expansion boards in, so I could upgrade the firmware, and now it seems to work.

        (sysname='WiPy', nodename='WiPy', release='1.7.3.b2', version='v1.8.6-667-gea97eb7e on 2017-06-16', machine='WiPy with E SP32')

        1 Reply Last reply Reply Quote 0
        • B Offline
          bm
          last edited by

          So this morning when I tried again it still doesn't work for pycom.rgbled(...).

          list(range(30)) works now, and everything else seems to work. Syntax errors and name errors seem to work fine, but eval'ing pycom.rgbled(0xff0000) makes the board restart.

          M 1 Reply Last reply Reply Quote 0
          • M Offline
            mmarkvoort @bm
            last edited by

            @bm

            For the pycom.rgbled(0xff0000), do you set the heartbeat to false first? Don't know if it is necessary for you.

            Link

            1 Reply Last reply Reply Quote 0
            • B Offline
              bm
              last edited by

              Yes. I disable the heartbeat and set a color as part of the BLE initialization.

              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