Handling an unexpected agent.send

edited November 2014 in Agent Code
I am using a Nora with the standard code from GitHub, works fine out of the box. When I try to change the agent-side calls to the Nora, even just to request five readings instead of four, I get the error "ERROR: no handler for agent.send()". I have no idea what is being sent, and the device code has several places where a string is sent such as wakereason, making this very hard to debug.

Is there any way to get more information about what the message is that has no handler? Or is it possible to set up a handler for unexpected sends from the device?

Comments

  • Sounds like you make the device send something to the agent, which you have not set it up for receiving. So when adding that extra thing you should know what you just added?

    But yes, it would be even easier if it was something like

    [Agent] ERROR: no handler for agent.send("test")
    instead of just
    [Agent] ERROR: no handler for agent.send()
  • Sadly I didn't write the code, it is an ElectricImp library which is sending all sorts of stuff that the corresponding agent is not equipped to handle. So I an trying to debug someone else's code and get it closer to working as intended.

    Thanks for the thought anyway, and I totally agree with your suggestion for displaying the offending message and even the payload. Or being able to write your own handler such as device.onunexpected(...)
  • More descriptive error messages are on the way. In the meantime you could try using a wrapper function on the device side to log the name of the event.

    function doSend(event, data) {
    server.log("sending: "+event)
    agent.send(event,data)
    }

    doSend("myevent", [1,2,3]) // replaces existing agent.send calls
  • edited November 2014
    I have just done exactly that, and I am trying to prod it into revealing all.

    By golly this is tricky to debug, as both the agent.send and the device.on are dynamically generated using sensor names and functions. I found that the device was sending "nora.read" when the agent was expecting "temperature.read". Clearly I need to power down the device or change the code just to make it forget the last requested function which is stored in nvram.

    At least I can now see what is going on, many thanks for the help
  • Error messages which indicate the name of missing agent.send() or device.send() handlers have finally been implemented, and will be deployed soon in releases for the imp (impOS 36) and agent. Sorry it took so long!
  • Very helpful. This sorts of messages are difficult to avoid when doing a firmware deploy, as the agent and device may restart out of sync with each other.
  • This sorts of messages are difficult to avoid when doing a firmware deploy, as the agent and device may restart out of sync with each other.
    We hope to fix this reasonably soon, as well.
  • ImpOS release 36 is going to beta this week - please look out for the announcements.
Sign In or Register to comment.