Debugging Instability on Vera

I am using Zerobrane Studio to debug my code running on Vera 3. I have some code that continuously runs, based on repeated activations from a timer. When I am debugging, the debug session terminates prematurely and these failures always coincide with the ZWave LED going out on the Vera. This happens every few minutes, the LED stays off for about 10 seconds before coming back on and the cycle repeating. Is this common behaviour and if is so does anyone know what is happening on Vera and if it can be controlled?

Sounds to me that Vera 's luup engine is restarting. Your code may be doing this.

  • Garrett

Garrett, you are right about the restart. I checked the LuaUpnp log at the time the light goes out and in amongst the log messages was this :

                Deadlock problem, going to reload and quit.

Any idea what conditions cause this?

I would stop what you are doing with your code to see if it still repeats. I have a feeling it’s your code / debugging.

  • Garrett

Thanks Garrett. You are right again. It is to do with my code but at the moment why the code I have removed would have this effect I can’t see. I will play with code to see if I can get a better understanding.

IIRC, there are challenges with long-running code (causing vera to restart)… I think the watchdog is ~20 seconds or so. (but that may not be relevant here)

@twostep, there is one thing you can try if the deadlock seems to be related to the debugging.

I think I’ve seen this once or twice long time ago and it seems to be related to the debugging being on when some internal Luup code is being executed. To give you an example. Let’s say you have some event and want to enable debugging for its code. Normally you’d do:

– event handler 1
require(‘mobdebug’).start()
– some other code here
require(‘mobdebug’).end()

But what if you now have two different event handlers and start debugging in one of them and end in another one:

– event handler 1
require(‘mobdebug’).start()
– some other code here

– event handler 2
– some other code here
require(‘mobdebug’).end()

This means that the debugging hook is set in one handler and after it ends and before the second event is triggered, the internal luup code is executed with the hook being on. On some occasions I noticed that it may lead to that deadlock message you saw. Unfortunately, since I don’t have access to the Luup code, I can’t tell what exactly may be going on there and how to avoid that.

The debugger provides two calls that allow you to temporarily turn debugging on/off if needed. This will still keep the debugging session opened, but will remove the hook, which should minimize any impact of debugging on the code being run.

You can modify the example above the following way:

– event handler 1
require(‘mobdebug’).start()
– some other code here
require(‘mobdebug’).off() --<-- turn debugging off before returning out of the event handler

– event handler 2
require(‘mobdebug’).on() --<-- turn debugging back on
– some other code here
require(‘mobdebug’).end()

I’m not sure if that’s your case, but it’s the only things that comes to mind by looking at the error message.