`eval` in BLE callback resets board

  • I have some code like this:

    def exec_handler(chr):
        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')

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

  • @bm

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


  • 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.

  • 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')

Log in to reply

Pycom on Twitter