ERROR: the index 'agent' does not exist

I keep getting the following error pinging every second or so in my device log. “ERROR: the index ‘agent’ does not exist”. I have stripped everything back and even when testing with the Blink Up example it still seems to be there. I have also tried running the Blink Up on a brand new imp with no resolve. The ‘Device’ code seems to run fine and the LED blinks as I want it but the error still keeps appearing. Any thoughts?

List your device code

Hi mlseim, my code is just the Blink LED example:

///////////////////////////////////////////

// assign pin9 to a global variable
led <- hardware.pin9;
// configure LED pin for DIGITAL_OUTPUT
led.configure(DIGITAL_OUT);

// global variable to track current state of LED pin
state <- 0;
// set LED pin to initial value (0 = off, 1 = on)
led.write(state);

// function to blink LED
function blink() {
// flip the state variable
if (state == 0) {
state = 1;
}
else {
state = 0;
}

led.write(state); // set LED pin to new value

imp.wakeup(2, blink); // schedule the blink function to run again in .5 seconds
}

blink(); // start the blink function

///////////////////////////////////////////

In the top right of the ‘Agent’ code side it says ‘stopped’, but every time the error is logged this flickers really fast to something (so fast I can not read it). I can’t remember what this normally says here as I have never had any problems like this before…

I have just created an entirely new account. Using the same hardware and code it seems to work perfectly, so there must be something up with my account right?

Are you dead sure you aren’t mentioning “agent” in your agent code itself, where it doesn’t exist?

Peter

Absolutely sure peter. There is no Agent code at all. With the new account I have created everything worked fine for a while but now I build and run my code, the agent says it’s running and then 5 seconds later says its stopped. Could it be an issue with wifi?

@mshorter - did you create a new model to test with the simplified code (before creating a new account)?

Put some agent code in there (eg just a single log). I suspect that there’s stale agent code (with a runtime error) in it, but because you now have no code in that side of the IDE, the old agent is still running.

Hi Hugo, that seemed to of fixed that problem, now something else has cropped up. I am running an example that I have used before http://www.instructables.com/id/Impower-The-Internet-Connected-AC-Outlet/ (thanks beardedinventor!). When I click build and run the device code it says it is loaded successfully. In the top right of the device code it says ‘online’. In the top right of the agent code it says ‘running’ for about 5 seconds and then says ‘stopped’. For that 5 seconds everything works as it should but then stops. Do you think this issue linked to my previous issues? Things aren’t going too smoothly for me of late…

Does seem a bit strange. Can you give us your device ID so we can look at what the agent is up to?

The device ID is 2363abeb6e4936ee. Cheers for the help! I have tried it with 3 different wifis and it is still doing the same thing…

Seems like you have an error in your agent code? I see the error “index agent does not exist”, coming from the agent.

The agent.send(), agent.on() calls only exist on the device side (to send messages to the agent and to register handlers for received messages).

The issue is not wifi related, it just seems like there’s a bug in your code - or you’re trying to run device code on the agent?

There definitely is not agent code in the device code or vice versa, I am using the exact same code as in Beardedinventor’s example… I have just replaced both the imp and breakout board uploaded the same code and everything works perfectly, so it must be a bug in that particular imp… Thanks for helping me figure out these bugs!

@mikeshorter - if you PM me your code I can take a look and see if I can reproduce with your issues with one of my imps.

moved to a new discussion,