Debugger for Z-Way JavaScript

Discussions about RaZberry - Z-Wave board for Raspberry computer
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Debugger for Z-Way JavaScript

Post by PoltoS »

We are happy to introduce Z-Way JavaScript engine debugger tool based on v8 debugger.

How to use it?

Install v1.7.1-rc1 (the only difference compared to v1.7.0 is the debugging available).

Install Node Inspector on your PC or on Raspberry Pi.

Add this line just after another "export" in /etc/init.d/z-way-server:

Code: Select all

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/z-way-server/libs
export V8_DEBUG=yes
Restart Z-Way:

Code: Select all

/etc/init.d/z-way-server restart
If Node Inspector is on your local manchine, make a tunnel to Raspberry Pi port:

Code: Select all

ssh -N pi@IP_OF_RASPBERRY_PI -L 8183:127.0.0.1:8183
Run Node Inspector:

Code: Select all

node-inspector --debug-port 8183
Then open Chrome and go to http://127.0.0.1:8080/debug?port=8183
Z-Way Debuggin using Node Inspector
Z-Way Debuggin using Node Inspector
Z-Way_Debugging.png (168.98 KiB) Viewed 30429 times
Enjoy!

NB! This is VERY experimental and sometimes v8 (and Z-Way) crashes if you try to inspect Z-Way internal (native) objects in JavaScript (for example, zway.devices and all others). So, do not watch them.

NB! Use old version of node-inspector. Check this: viewtopic.php?f=3419&t=24237&p=66327#p66054
Last edited by PoltoS on 09 Jun 2014 01:03, edited 1 time in total.
User avatar
alexey.zimarev
Posts: 24
Joined: 16 Oct 2012 17:54

Re: Debugger for Z-Way JavaScript

Post by alexey.zimarev »

This is a big thing! So tired of console.log...

It is also very exciting to see signs of Node in Z-Way :)
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Debugger for Z-Way JavaScript

Post by PoltoS »

There are no signs of Node in Z-Way at all. We just use same v8 as NodeJS uses.

But NodeJS have a visual debugger. You can instead use v8 internal debuggin tool.
billyboy
Posts: 61
Joined: 16 Mar 2013 21:33

Re: Debugger for Z-Way JavaScript

Post by billyboy »

should port 8183 not be port 8083?
If not then Node Inspector is running but I don't see any files, if not then Node Inspector crashes with a error 500: Servewr Error, SyntaxtError: Unexpected token E.
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Debugger for Z-Way JavaScript

Post by PoltoS »

Should be exactly 8183!
billyboy
Posts: 61
Joined: 16 Mar 2013 21:33

Re: Debugger for Z-Way JavaScript

Post by billyboy »

I tried everything but node inspector start, the webpage loads but I don't see a script file or running code.
If I press Ctrl+O it opens a window but this is empty?
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Debugger for Z-Way JavaScript

Post by PoltoS »

have you started Z-Way with V8_DEBUG=yes on the SAME machine or with ssh tunneling?
billyboy
Posts: 61
Joined: 16 Mar 2013 21:33

Re: Debugger for Z-Way JavaScript

Post by billyboy »

Yes, i added V8_DEBUG=yes to /etc/init.d/z-way-server.
I installed Node Inspector on the Raspberry.
And started it: node-inspector --debug-port 8183 (via telnet)
billyboy
Posts: 61
Joined: 16 Mar 2013 21:33

Re: Debugger for Z-Way JavaScript

Post by billyboy »

It works now!
I updated to 1.7.1 and node inspector works now.
Just finding out how to use it.
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Debugger for Z-Way JavaScript

Post by PoltoS »

Nice! Do you have some howto for installation of node-inspector on RPi? We use it through ssh tunnel, but may be you can share with others this?
Post Reply