The Vera Community forums have moved!

Advanced => Programming => General => Topic started by: paulclinger on November 27, 2013, 07:08:37 pm

Title: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 27, 2013, 07:08:37 pm
Hi twostep, jasperhb, RexBeckett, and others,

Thank you for your interest in ZeroBrane Studio integration with Vera. I'm pleased to announce that the product is available for purchase and download at http://studio.zerobrane.com/vera.html. I know, it's been coming soon for several weeks, but I wanted to make sure I incorporate all the feedback from the early users and provide documentation that will make it easier to start using the product.

I'd like to thank all the beta testers, who not only took time to test the product and provide their feedback, but also reviewed and updated the documentation (https://studio.zerobrane.com/vera-documentation.html).

I'll briefly go over its features to provide a summary for those who may be new to the product. The main aspect that should be of interest to most of you is the debugging on the device. You can run Lua code from the IDE and make it execute on the device; not only that, but you can also step through the code, look at the stack and variables, run any Lua and luup commands in the remote console, modify variables there and more (https://studio.zerobrane.com/vera-debugging.html).

You can also initiate debugging from the device (https://studio.zerobrane.com/vera-remote-debugging.html), which allows to debug Lua code running as part of scenes or plugins. It is setup a bit differently from the "regular" debugging you initiate from the IDE, but otherwise provides access to the same functions (stepping, breakpoints, remote console, and everything else).

The IDE also provides auto-complete and tooltips for Luup functions, support for editing XML files, and ability to upload files to the device, download LuaUPnP.log, and restart the Luup engine on the device.

There are two more things that may help with debugging and troubleshooting Lua scripts. You can use print() expressions when debugging and their result will be redirected to the Output window in the IDE. This is a lightweight alternative to luup.log calls. Not only that, but the output is going to be pretty-printed, which means that print(mytable) will print the table content. You can also use pretty printing in several other places in the IDE, for example, in the Console and in the Watch window.

The last thing I'll mention is the code analyzer that checks your code for typos and subtle errors.

Onto the pricing. The current introductory price includes 40% discount that is likely to be available through the holidays till the end of the year. You can choose between non-commercial (hobby and learning) and commercial options. I also have subscription plans for those who need work with more than one device. If you need any special arrangements, you can email me at support@zerobrane.com.

Please let me know if you have any questions/suggestions or come across any issues; I'll keep an eye on this thread and other forum posts. You can also find me on freenode IRC in #zerobrane or email me. Thank you.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on November 27, 2013, 10:18:01 pm
Hopefully it speeds up software development for vera. The licence agreement doesn't seem to be appealing though.

"ZeroBrane LLC reserves the right to publish a selected list of users of the Software." why?

"ZeroBrane LLC reserves the right to make changes to this License at any time without notice to you. It is your responsibility as a user of this Software to periodically return to this page to review...."  Need to put a periodical reminder on my calendar ...
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 27, 2013, 11:46:32 pm
> Hopefully it speeds up software development for vera. The licence agreement doesn't seem to be appealing though.

Thank you for the feedback!

> "ZeroBrane LLC reserves the right to publish a selected list of users of the Software." why?

So that I could use it as a reference, but I agree; it does look better without it.

> "ZeroBrane LLC reserves the right to make changes to this License at any time without notice to you. It is your responsibility as a user of this Software to periodically return to this page to review...."  Need to put a periodical reminder on my calendar ...

This was something that was suggested by my attorney, although it applies more to services, than to products.

I updated the license to remove both of these; should look shorter and simpler now.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on November 28, 2013, 12:31:08 am
I totally understand the pain of developing this and I hope you make heck lots of money :-)
Maybe what you need is a personal license and a business license. In business license, it seems to be fine to publish the user name.

You can update the license, but what you have sold is probably going to remain under the older license.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 28, 2013, 12:38:53 am
You can update the license, but what you have sold is probably going to remain under the older license.

Correct (it's all version controlled anyway). I don't think it's worth splitting to personal/commercial over this as I can always ask for a permission in either case.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: Weeves on November 28, 2013, 12:47:33 am
@Paul,

  am I right in thinking that it won't upload .xml files (greyed out in the I_XXXX.xml I'm looking at)

 also, it would be nice to download files from the vera as well.

certainly a lot easier than blind editing!

Cheers
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 28, 2013, 12:55:47 am
> am I right in thinking that it won't upload .xml files (greyed out in the I_XXXX.xml I'm looking at)

It will; it will upload any files you have, but only during a debugging session. Note that it won't compress the files.

> also, it would be nice to download files from the vera as well.

It downloads the log file (also during the debugging), but I could not come up with a good interface to get the list of files and select one to download. Also, if you use Vera upload, those files are likely to be compressed and the download through ZBS won't help as it can't decompress them.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 28, 2013, 01:09:08 am
> also, it would be nice to download files from the vera as well.

@Weeves, not quite as straightforward as downloading to a new window, but you can also run something like this in the console (while debugging is in progress):

io.open('/etc/cmh-ludl/whatever.lua'):read('*a')

This should print the (serialized) content of the file in the console. The output is limited to 400 characters, but this can be changed in the config file (this is fixed in the next version).

> certainly a lot easier than blind editing!

That's the goal; thank you!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: Weeves on November 28, 2013, 01:39:28 am
@Paul,

I think I found why I can't upload a file - it's throwing a compilation error :
Compilation error on line 201:
[string "D:\Users\Joe\Documents\Vera Files\L_IPhone.lua"]:201: invalid escape sequence near '"'

the line in question is executed successfully in the vera, but ZBS seems to object to it

                          function escapeQuotes( str )
this line ---->      return str:gsub("\'", "\\'"):gsub("\?", '\\?'):gsub('\"','\\"') -- escape quote characters
                          end
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 28, 2013, 02:35:49 am
@Weeves, yes, \? is an invalid escape. ZBS is using LuaJIT interpreter internally, which is a bit more strict about escape sequence and will complain even when Lua 5.1 allows those to go through. You can just replace "\?" with "?" in your script.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on November 28, 2013, 01:14:59 pm
Good job, @paulclinger, this works really well. I think it should be very helpful to people starting-out with Lua/Luup programming for Vera scenes and plugins. I would say it was good value at the current offer price.

It would be good if the Documentation entry in the Help menu included links to the Vera-specific documentation. Also a link to the Lua Reference Manual would be very useful.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on November 28, 2013, 10:57:10 pm
@paulclinger,
do u accept Paypal?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 29, 2013, 12:40:30 am
> do u accept Paypal?

@persimmonx, I do, but I don't want to enable it as one of the payment options for various reasons. I really like Stripe integration and I don't have any access to the credit card information, but if you prefer paypal, please email me at support@zerobrane.com and I'll send you payment information.

If you don't mind me asking, is paypal much better than the current payment option? I don't store this information and I don't think that Stripe stores it either; everything goes over https, so it should be fairly secure.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 29, 2013, 01:00:12 am
> Good job, @paulclinger, this works really well.

@RexBeckett, thank you for the feedback!

> It would be good if the Documentation entry in the Help menu included links to the Vera-specific documentation. Also a link to the Lua Reference Manual would be very useful.

That's a great point; the links should all point to the Vera-specific resources as you suggested. I'll add it in the next version.

In terms of Lua Reference Manual, I can add a link, but I can actually do better. I have a plugin that adds a context menu item when you use it on a particular function (like "print" or "io.open") and it will open the manual page in the browser for that particular function. The plugin and instructions are in this post: http://www.freelists.org/post/zerobrane/Unsolicited-feature-wishlist,1
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on November 29, 2013, 12:02:21 pm
Quote
In terms of Lua Reference Manual, I can add a link, but I can actually do better. I have a plugin that adds a context menu item when you use it on a particular function (like "print" or "io.open") and it will open the manual page in the browser for that particular function. The plugin and instructions are in this post: http://www.freelists.org/post/zerobrane/Unsolicited-feature-wishlist,1
Thank you, @paulclinger. The showluareference plugin works well. Actually I think it works better than the context-sensitive help in MS Visual Studio.  ;D
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on November 29, 2013, 04:07:07 pm
> do u accept Paypal?

If you don't mind me asking, is paypal much better than the current payment option? I don't store this information and I don't think that Stripe stores it either; everything goes over https, so it should be fairly secure.

Yes, Paypal is much more appealing if one are buying over internet. I know you said you don't store credit card info, but in theory, the buyer cannot be sure. Besides, processing credit card info requires PCI compliance, and again, users aren't sure if the seller actually has it.

Personally, I don't provide credit card info online, unless I am buying from a major company or paying by Paypal, Google wallet or Amazon checkout .

Regards.


Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 29, 2013, 04:55:47 pm
> Besides, processing credit card info requires PCI compliance, and again, users aren't sure if the seller actually has it.

@persimmonx, I agree; it's a valid concern. The advantage of using Stripe is that it allows me to satisfy PCI compliance without capturing and protecting CC info on my side. You (as a user) indeed can't be sure, but you can inspect the JavaScript code to verify that I follow Stripe guidelines and don't get CC information (not that you need to, but you could).

As to the other payment methods, I may provide Amazon payments as an alternative, but a bit later.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 30, 2013, 03:59:50 pm
also, it would be nice to download files from the vera as well.

@Weeves, agree. I added loading/editing/saving files from the device; see this post for details: http://forum.micasaverde.com/index.php/topic,17807.0.html. Give it a try and let me know how it works for you.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: Weeves on November 30, 2013, 10:37:11 pm
didn't work for me:

Debugging session started in 'D:\Users\Joe\Documents\Vera Files\'.
Failed to load file 'L_SmartSwitch_core.lua': L_SmartSwitch_core.lua: No such file or directory.

that lua file is one of the few that isn't compressed.

Do I need to add a path?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on November 30, 2013, 10:39:46 pm
> Failed to load file 'L_SmartSwitch_core.lua': L_SmartSwitch_core.lua: No such file or directory.
> Do I need to add a path?

@Weeves, yes, put in a full path as it can get a file from any folder. I may add /etc/cmh-ludl by default if a relative path is detected.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: Weeves on November 30, 2013, 11:46:28 pm
Yep - that works!
a default would be good.

Cheers
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 01, 2013, 12:23:51 am
@Weeves, it just opens the file in the current directory. Since the current directory is set to "/" by default, it doesn't find the file if it's in a subdirectory.

You can change the directory by running lfs.chdir('/etc/cmh-ludl') (or whatever value you need) from the Console when debugging is in progress. This should set it until luup is restarted. You can then open a file using just the file name. I just tested it and it works. In fact, you can probably add it to the startup script if you want.

Also, I've been thinking about adding "remote:" indicator to the tab name. Do you think it would be useful?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: SOlivas on December 03, 2013, 09:54:51 am
Glad to see that this is taking off.

Thanks for letting me be a beta tester.  It is a pretty cool program.  While lately I've been occupied with work and a few other things, when I get a chance to put more time back into HA, I will be using this to push forward with my mods to the plugins I've done.

Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: hifs on December 04, 2013, 09:50:40 pm
I just thought I'd throw some positive feedback out there. I'm not affiliated with the author of this software, but went ahead and purchased a copy of the Vera edition after playing around with the non-Vera integrated version for a few weeks. I had recently posed a question about intercepting http requests initiated outside of the Vera in the MiCasaVerde forum and was pointed toward using lug_WapRequest. I tried some code in ZeroBrane Studio for Vera and at first did not have success, but then posed a question to the ZeroBrane support team. They quickly responded and pointed out the minor change I needed to make. I was able to debug my code fairly quickly. I also used it to debug some luup.variable_watch commands and the IDE allowed me to intercept the events. I'm quite impressed that these work and look forward to spending more time in this IDE!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 06, 2013, 02:00:36 am
@hifs, @SOlivas, thank you for the feedback!

> I had recently posed a question about intercepting http requests initiated outside of the Vera in the MiCasaVerde forum and was pointed toward using lug_WapRequest.

I updated the documentation with some examples of how debugging works for plugin "startup" code and request (register_handler) callbacks: http://studio.zerobrane.com/vera-documentation.html. I'm also adding other sections and will update when they are posted.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: twostep on December 07, 2013, 05:40:58 pm
Using the Zerobrane Output window when remote debugging.

I have a long running Vera process which, when testing, I write messages to the Vera log for later review. This is not ideal because there are a lot of other messages going to the Vera log so it is necessary to copy this file and filter it to see all my messages contiguously, and the size of the log in Vera can be a problem and cause instability. I would prefer to use Zerobrane for this debugging to make use of the pretty print facility in conjunction with the Output window. Is it possible to configure Zerobrane to also write text written to the Output window to a file on the system where Zerobrane is running. This would avoid the issues around using the Vera log. I can then start a Zerobrane remote debug session, leave it running and later, review the captured file.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 07, 2013, 08:15:48 pm
> I would prefer to use Zerobrane for this debugging to make use of the pretty print facility in conjunction with the Output window. Is it possible to configure Zerobrane to also write text written to the Output window to a file on the system where Zerobrane is running. This would avoid the issues around using the Vera log. I can then start a Zerobrane remote debug session, leave it running and later, review the captured file.

@twostep, this is a very interesting idea! I put together a simple plugin to test this functionality: http://notebook.kulchenko.com/zerobrane/saving-debugging-output-to-file. It will write to output.log file in the current project directory, but you can change that in the config file. It will also "trim" the output to the last 100 lines in the Output window, so you can run long sessions without using much memory.

All the writes to the log file are flushed immediately, so you can check the file while the process is still running. Please let me know if you run into any issues with it.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on December 07, 2013, 08:40:04 pm
Not wishing to minimize the advantages of ZeroBrane Studio, you could also just write your logs to a text file in Vera with something like:

Code: [Select]
local value = 123
local time = os.date()
local file = io.open("/www/log.txt", "a")
file:write("Log " .. time .. " Value: " .. value .. "\n")
file:close()

You can review the results in your browser through <veraipaddress>/log.txt
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 08, 2013, 12:31:24 am
RexBeckett, I'm sure there are good alternatives ;); thank you for providing one.

I think two main advantages of using remote printing in ZBS are that the output is pretty-printed (with tables expanded in the output) and it doesn't require code changes in your scripts (assuming you do "printing" anyway). Also, since the log is already stored locally, you can simply delete the file between sessions if you want to truncate it.

The advantage of your method is that you don't need any additional tools to collect this in a log file.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: twostep on December 11, 2013, 10:38:06 am
One of the problems I have found with logging on Vera is that if significant amounts of logging occurs, Vera can become unstable. Using a separate local log for minimal runtime logging is much better to isolate it from the Vera log but in actual debugging sessions, getting the data back on the client is a good option for me. Horses for courses I guess. It's good to have the choice.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: ttmetro on December 12, 2013, 12:09:14 am
> Good job, @paulclinger, this works really well.

@RexBeckett, thank you for the feedback!

Tried the tutorial (local sunset = luup ...) but things are not working as expected.

Output:
Code: [Select]
Trying to detect Vera device address from mios.com...
Debugger server started at Moncrino:8172.
Connecting to Vera device at 192.168.20.13:3480...
Program starting as '"C:\Programs\ZeroBraneStudioForVera\bin\lua.exe" -e "loadstring(require('mime').unb64('G0xKAQCmBGxvY2FsIHMgPSByZXF... '))()"'.
Program 'lua.exe' started in 'C:\Users\Bernhard Boser\Documents\Files\Personal\Automation\Vera\plugins' (pid: 1168).
Program completed in 189.65 seconds (pid: 1168).

Now way to pause or stop the program either. Just sits there, and when I already thought it was broken, it suddenly decided it was finished now. Same problem with a print statement only.

What's wrong?


Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 12, 2013, 01:39:34 am
> Now way to pause or stop the program either. Just sits there, and when I already thought it was broken, it suddenly decided it was finished now. Same problem with a print statement only.

@ttmetro, Thank you for the report. It seems like the IDE doesn't receive the debugging request from the device. It may happen for several reasons:

1. You have a firewall that blocks incoming connections to port 8172.

2. The IDE incorrectly detected the hostname, which is then given to the application that will connect to the IDE to start debugging. IN your case the hostname is shown as "Moncrino" (Debugger server started at Moncrino:8172.), but it's possible that this address doesn't resolve when used from the device. You can configure the hostname to use instead of auto-detected one by going to "Edit | Preferences | Settings: System" and adding

debugger.hostname = 'ip-address-of-PC-with-IDE'

Save the file and restart ZBS and then try starting the debugging again.

3. If nothing else works, it's possible that the debugger component was not correctly set on the device. You can reset the saved configuration and try to set the debugger again, which may resolve this issue. Run the following command from the Local console in ZBS (just replace 35......22 with the full number of your device):

(function() local s = ide.packages.vera:GetSettings(); s['35....22'] = nil; ide.packages.vera:SetSettings(s) end)()

You can then try the debugging again. Please let me know if one of these steps resolves the issue. I'll update the troubleshooting section in the documentation. Thank you. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on December 12, 2013, 02:35:36 am
doesn't connect to Vera:

Trying to detect Vera device address from mios.com...
Debugger server started at xxxxxxx:8172.
Connecting to Vera device at 192.168.1.101:3480...
Failed to connect to Vera device after 3 seconds.


It didn't prompt for the key.

Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 12, 2013, 11:50:35 am
> Connecting to Vera device at 192.168.1.101:3480...

@persimmonx, was the address of the device detected correctly (192.168.1.101)? Can you ping that address from the computer running ZBS? At this point the IDE will attempt to contact the unit using this URL (http://192.168.1.101/cgi-bin/cmh/online_check.sh?tmp=1) and will report failure after 3s if the unit doesn't respond. You can test that URL manually and if everything works, just start the debugging again from the IDE.

> It didn't prompt for the key.

It would be the next step after the unit is detected.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on December 12, 2013, 12:18:42 pm
yes 192.168.1.101 is the address of my Vera. I ssh to Vera from the computer I am running ZBS from.
The URL you send works correctly and returns: test({"PK_AccessPoint":"30004165"});
But still IDE gives the same message and doesn't connect!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 12, 2013, 01:41:16 pm
> yes 192.168.1.101 is the address of my Vera. I ssh to Vera from the computer I am running ZBS from.
> The URL you send works correctly and returns: test({"PK_AccessPoint":"30004165"});
> But still IDE gives the same message and doesn't connect!

That's interesting. My apologies for the inconvenience.

Can you try running the following two commands in the Local console of ZBS:

> package.path = package.path..';'..MergeFullPath(ide.editorFilename,'../lualibs/?.lua')
> require('socket.http').request('http://192.168.1.101/cgi-bin/cmh/online_check.sh?tmp=1'):match('"PK_AccessPoint":"(.+)"')

Also, what OS are you running this on?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 12, 2013, 01:48:00 pm
@ttmetro,

> debugger.hostname = 'ip-address-of-PC-with-IDE'

I need to correct myself; the Vera component will overwrite "debugger.hostname" value with the IP address it detects based on the result of following code: "socket.dns and socket.dns.toip(socket.dns.gethostname())". Can you run it in the Local console of ZBS to see what it returns:

> socket.dns and socket.dns.toip(socket.dns.gethostname())

It should return the IP address of the computer running the IDE, but depending on your network configuration it may pick the wrong address.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: ttmetro on December 13, 2013, 09:23:52 pm
> Now way to pause or stop the program either. Just sits there, and when I already thought it was broken, it suddenly decided it was finished now. Same problem with a print statement only.

@ttmetro, Thank you for the report. It seems like the IDE doesn't receive the debugging request from the device. It may happen for several reasons:

1. You have a firewall that blocks incoming connections to port 8172.

Firewall was the problem.

     socket.dns and socket.dns.toip(socket.dns.gethostname())

does return the IP address of the local host.

Thanks,
Bernhard
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 13, 2013, 11:21:17 pm
> Firewall was the problem.
>   socket.dns and socket.dns.toip(socket.dns.gethostname())
> does return the IP address of the local host.

Bernhard, so are you up and running after the firewall change? Please let me know if I can help with anything else.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: ttmetro on December 14, 2013, 10:51:38 pm
Yes, after opening the firewall it's working fine now!

Many thanks!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on December 16, 2013, 05:29:42 am
I've been using ZBS to single-step through Luup code chunks prior to dropping them into plugins. It is a great way to spot those typical errors like misspelled service IDs that can be hard to track-down in running code. I think this is a really useful tool for developing Luup code for Vera scenes and plugins.

Thanks, @paulclinger, you have made the debugging process much, much easier.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on December 18, 2013, 02:34:40 am
It there anyway we can ask the ZBS to detect undeclared variables at compile time?

Thanks!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 18, 2013, 10:41:02 am
> It there anyway we can ask the ZBS to detect undeclared variables at compile time?

@persimmonx, yes, in two ways. First of all, while you type, ZBS detects the scope (global/local) of a variable and adds an indicator to it: global variables are underlined with a solid line and local with a lightly dashed on. Screenshots and further details are in this post: http://notebook.kulchenko.com/zerobrane/scope-aware-variable-indicators-zerobrane-studio. The page also described how you can rename local variables, show all instances, and go to definition.

The second option is to use static analyzer (Project | Analyze or Shift-F7). It does code analysis of the current file and lists all global variables used or assigned to and detects some other subtle errors as well.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: persimmonx on December 18, 2013, 06:30:33 pm
Thanks, that is a life saver. I already found a couple of misspelled variables.

Why does it give a message like the following for loop variables?

Quote
unused local variable 'i'; consider removing or replacing with '_'
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 18, 2013, 09:44:21 pm
> Why does it give a message like the following for loop variables?
> unused local variable 'i'; consider removing or replacing with '_'

This is when you have a loop variable that you don't use inside the loop; for example,

for i = 1, 2 do print() end

Since "i" is not used anywhere it gives you a warning. Just replace it with _:

for _ = 1, 2 do print() end

The same way, if you use pairs/ipairs, but only need one value, you can do:

for _, v in pairs(t) do print(v) end
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: jduchon on December 22, 2013, 03:39:56 am
Hello Paul,
I'm glad I've found your IDE for my Veralite! Thank you.

However, I have the IDE not successfully connecting :

Quote
Trying to detect Vera device address from mios.com...
Debugger server started at Mac-Dusson.local:8172.
Connecting to Vera device at 192.168.2.156:3480...
Failed to connect to Vera device after 3 seconds.

The device ID returned by
Quote
http://192.168.2.156/cgi-bin/cmh/online_check.sh?tmp=1
is correct and I've no firewall between my Mac and the Vera.

I'm on Mac OS 10.9.1.

Thank you,

Jerome
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on December 22, 2013, 11:14:44 am
Hi Jerome,

> I'm glad I've found your IDE for my Veralite! Thank you.
> However, I have the IDE not successfully connecting :

This may happen for two reasons:

1. You have basic authentication enabled on your device.
2. The address of the computer running the IDE is not correctly detected; this address is needed for the debugger to make the call from the device to the IDE to start debugging.

I have an updated version of the Vera integration code that works with basic authentication and provides a way to set the address of the IDE if it's incorrectly detected. Please send me an email to support@zerobrane.com and I'll send you the updated version to try. Thank you. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: CoreDex on January 04, 2014, 05:25:09 pm
I just wanted to share my experience with ZeroBrane Studio's support.  I recently purchased it to do sum scripting with Vera.  I had a problem connecting to my Vera because I had basic authentication enabled.   Paul responded with excellent and very timely support to an email I sent (within minutes) and walked me through the issue.  He has an update as noted in this thread to allow the IDE to work with basic authentication enabled and it worked well.

Just starting to use the app, but I expect it will be very helpful as I've found troubleshooting code on the Vera to be most tricky.

I just wanted to share my recommendation.


Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: swat on January 20, 2014, 05:17:12 am
> Good job, @paulclinger, this works really well.

@RexBeckett, thank you for the feedback!

Tried the tutorial (local sunset = luup ...) but things are not working as expected.

Output:
Code: [Select]
Trying to detect Vera device address from mios.com...
Debugger server started at Moncrino:8172.
Connecting to Vera device at 192.168.20.13:3480...
Program starting as '"C:\Programs\ZeroBraneStudioForVera\bin\lua.exe" -e "loadstring(require('mime').unb64('G0xKAQCmBGxvY2FsIHMgPSByZXF... '))()"'.
Program 'lua.exe' started in 'C:\Users\Bernhard Boser\Documents\Files\Personal\Automation\Vera\plugins' (pid: 1168).
Program completed in 189.65 seconds (pid: 1168).

Now way to pause or stop the program either. Just sits there, and when I already thought it was broken, it suddenly decided it was finished now. Same problem with a print statement only.

What's wrong?

I also tried to run the example code, but nothing worked.
I found a description for remote debugging.
http://studio.zerobrane.com/vera-remote-debugging.html
There is specified that can be run using the debug code.

require ('mobdebug'). start ()

I added code to the beginning of this line and it worked.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: jl8813 on January 22, 2014, 08:53:23 pm
> Besides, processing credit card info requires PCI compliance, and again, users aren't sure if the seller actually has it.

@persimmonx, I agree; it's a valid concern. The advantage of using Stripe is that it allows me to satisfy PCI compliance without capturing and protecting CC info on my side. You (as a user) indeed can't be sure, but you can inspect the JavaScript code to verify that I follow Stripe guidelines and don't get CC information (not that you need to, but you could).

As to the other payment methods, I may provide Amazon payments as an alternative, but a bit later.

This looks great, and I'd love to buy it, but I'm not buying until PayPal or Amazon payment is added.  I'm just not comfortable giving my card out to a bunch of small third party services.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on January 22, 2014, 10:12:32 pm
Hi jl8813,

> This looks great, and I'd love to buy it, but I'm not buying until PayPal or Amazon payment is added.  I'm just not comfortable giving my card out to a bunch of small third party services.

No problem; I sent you a PM with information on where you can send a PayPal payment.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: jl8813 on January 28, 2014, 10:40:33 am
Hi jl8813,

> This looks great, and I'd love to buy it, but I'm not buying until PayPal or Amazon payment is added.  I'm just not comfortable giving my card out to a bunch of small third party services.

No problem; I sent you a PM with information on where you can send a PayPal payment.

Paul.

Thanks for working with me on this!  Working great!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: oTi@ on January 31, 2014, 08:46:09 pm
Luup sandbox out; ZeroBraneStudio remote console in.

Good stuff! 8)
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on February 11, 2014, 10:22:08 pm
I updated the FAQ with information on how to restore debugging after a hard reset of your Vera device: http://studio.zerobrane.com/vera-faq.html. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on February 25, 2014, 04:35:43 am
Recently my ZeroBrane Studio is causing a Vera restart whenever the Lua code ends - either naturally or by clicking the stop button. This happens almost every time and with even the simplest code. I am running this on a Vera3 1.5.622 with at least 40MB of free memory. For example, running this:

Code: [Select]
local v = 2
Gave this in the Output tab:
Code: [Select]
Program 'lua.exe' started in 'C:\Users\Rex\Documents\Vera\Lua' (pid: 16524).
Debugging session started in 'C:\Users\Rex\Documents\Vera\Lua\'.
Code execution failed.
Restarting Luup engine on Vera device...........Done.
Debugging session completed (traced 0 instructions).
Program completed in 18.39 seconds (pid: 16524).

What can I do to fix it?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on February 25, 2014, 11:21:00 am
@RexBeckett,

> Recently my ZeroBrane Studio is causing a Vera restart whenever the Lua code ends - either naturally or by clicking the stop button. This happens almost every time and with even the simplest code.

Are you running this using Debug or Run? Can you try Debug if you haven't tried already as it is likely to give you the actual error message that Run doesn't provide (as lu_action doesn't return any results).

If that doesn't help, can you try following the instructinos for restoring the debugging component (in the FAQ) that was posted right before your message? Please let me know if that resolved the issue. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on February 25, 2014, 12:07:24 pm
Thanks, Paul.

I always use Debug (F5) to run the code. Where do you think the additional error information should be displayed? I also had tried:
Code: [Select]
ide.packages.vera:SetSettings({regkey = ide.packages.vera:GetSettings().regkey})in the Console but it didn't change anything.

Trying it just now, it seems to be OK... It's been happening for several days and now it just stopped... If it happens again, what can I capture to figure-out what is causing it?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on February 25, 2014, 01:06:14 pm
> Trying it just now, it seems to be OK... It's been happening for several days and now it just stopped... If it happens again, what can I capture to figure-out what is causing it?

Usually, when execution fails using Run, the IDE can't get any error information, but when using Debug you should see the error message in the Output window of the IDE.

If the opposite case happens, when the execution shows "Code execution failed." when doing Debug, but not Run, it may mean that the debugger component is damaged or absent (for example, after a unit reset). To quickly check if it's indeed related to the debugger component or not without using ZBS, you can try the following command in the Test Lua tab: require('mobdebug').off(). If it gives you "Code execution failed." message in the vera UI, then there is something wrong with the debugger component, in which case that command from the FAQ you showed should help.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: parkerc on March 02, 2014, 02:42:28 pm
As I'm not a programmer (sorry @Rex) I'm not up to speed with all the terms/expressions used etc,  (the lingo) nor do I think my head is  wired in the way it needs to be to easily grasp it and do it well, but even after saying that, I do enjoy working out the Luup code needed to do certain things with Vera. Well, I guess we all need a hook, that'll get us into something. ;)

So just how good is this product as a learning tool?

@Rex has just been signing it's praises to me, but - I wanted to ask/see if there were any novices out there who'd bought it and felt that it really helped them ?

I have so many plugins I want to make, but so little time to do it, but I'm wondering if this investment will allow me to maybe realise one or two of them ?

Please let me know your thoughts..
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RichardTSchaefer on March 02, 2014, 04:39:36 pm
@parkerc
I do not want to discourage you from learning more and using the same tools that developers use.

However there is a learning curve just to learn how to use an IDE (Integrated Development Environment).  Many IDEs have similar organization, to make it easier for developers to work in multiple ones. In the past week alone, I have used Visual Studio IDE (Microsoft), Eclipse (Android + Java + Google App Engine),  + NetBeans (Older Java) + XCode (Apple IDE). But many of the concepts will be foreign to a non developer.  And even though they are all similar it often takes me a couple weeks with each to get familiar with the components in the IDE to use it effectively.

If you want to seriously develop code ... than it would be a good investment in time (believe me the license fee is insignificant compared to the time commitment you will need).
If you just want to play around with LUA syntax to write a some code for conditional LUA ... Install LUA for Windows. You can play around and learn the LUA language.

NOTE: An IDE does not help you learn the LUA language any faster than LUA for Windows.  It can help to debug why some LUA code (that you already understand) may not be working as expected (because you forgot to handle certain boundary conditions).

Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: TC1 on March 02, 2014, 06:18:40 pm
I pretty much agree with what RTS said, you can pretty much programm with with just a plain text editor if you wanted to. What a good IDE will do you for you, besides help in the debugging process, is do dynamic syntax checking while you actually type. Think of it as MS Word's spelling and grammar checker. While you are writing code it is constantly checking to see if you are doing something wrong or unexpected in terms of the language usage, and will highlight mistakes. Just like Word though, it won't stop you from writing lousy code  :P
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 02, 2014, 06:28:21 pm
So just how good is this product as a learning tool?

@Rex has just been signing it's praises to me, but - I wanted to ask/see if there were any novices out there who'd bought it and felt that it really helped them ?

I'm not sure about novices to Vera, but I've been teaching an introductory computer science class at a local high school using Lua and ZeroBrane Studio and students without any programming experience made good progress; there were several teams that were implementing compression and steganography by the end of the quarter long class.

You may follow RichardTSchaefer's advice and try LuaForWindows; if you are on the fence about buying ZBS for Vera, you can try ZeroBrane Studio itself and check the capabilities it provides. It comes with a simple tutorial and more than 50+ demos and examples for Lua.

The IDE uses the same editor component as LuaForWindows (it's based on Scintilla), but it provides more advanced debugger and should let you run and debug your scripts out of the box. It doesn't include any additional modules you may need for general Lua development (and LfW comes with plenty of modules), but you can get additional modules from LuaDist or use LfW modules you already install if needed. If you haven't seen the tutorial for Vera debugging (http://studio.zerobrane.com/vera-tutorials.html), you may check it to see what is supported.

Being the author of the tool I may be biased, but I had two goals for this ZBS-for-Vera project: simplify the debugging for experienced plugin developer and make the process more approachable and convenient for new developers who may not be familiar with Lua and programming. I'd be interested to see feedback on how easy to use the IDE is and what can be improved.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: RexBeckett on March 03, 2014, 05:51:09 am
There is an important difference between LuaForWindows and ZBS-for-Vera: Both of these IDEs can run and debug Lua but only ZBS-for-Vera can execute and debug Vera's luup functions.

Many times when people request help to fix their non-working code, the problem is with a luup function. Typical problems are using the wrong ServiceID string, the wrong device variable name or trying to use a string in a numerical comparison. These problems are immediately apparent when single-stepping through the code in ZBS-for-Vera.

I have no axe to grind here. I use both of these IDEs. They are both good at what they do and are equally easy to use.  If you want to be able to run and debug your whole scene code (with actual responses from the devices), though, only ZBS-for-Vera can do that.


Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: aechelon on March 05, 2014, 10:21:53 pm
I'd like to share my experience for anyone who's on the fence about purchasing ZeroBrane.

I'll preface by saying that I'm a developer with a fair amount of Linux experience, so my point of view may be a little skewed.

I'm relatively new to Home Automation.  I purchased a VeraLite a couple of months ago and had zero experience with either the Vera hardware or Lua before then.

With little time available to devote to the Vera I've stumbled my way through managing devices and scenes and started working on my first plug-in (see http://forum.micasaverde.com/index.php/topic,14928.0.html (http://forum.micasaverde.com/index.php/topic,14928.0.html))

Given my inexperience with Lua, I started with the more familiar (yet far more painful) approach of cross-compiling C++ binaries to OpenWRT 10.03 (Backfire).  (For anyone with interest in doing that I've posted a full development stack in the lhh repository here: http://code.mios.com/trac/mios_lhh/browser/development (http://code.mios.com/trac/mios_lhh/browser/development) )

That worked great and all, but it's complete overkill if your end goal is to develop plug-ins for the Vera... Provided you have the right set of tools!

Which brings me to ZeroBrane. 

For the past couple of weeks I've been SCP'ing files back and forth to the Vera and debugging by grep'ing for print statements through logfiles -- which in the age of visual debuggers is about as much fun as poking yourself in the eye with a sharp stick!

After reading through this thread I exchanged a few emails with Paul before purchasing a license. 

Installation involved unzipping a file.  That's it. 

The IDE is small and completely self-contained (which is great for those of us who prefer being minimalists!)

After installation I jumped directly into the Vera tutorial on the ZeroBrane website.  I immediately ran into a couple of issues due to my network configuration.  Paul responded to support requests within minutes and I was debugging my own plug-in within an hour!

Compared to what I was doing before, using ZeroBrane is a breath of fresh air!  I've gained more ground on the plug-in the past few hours than I had in the previous week.
I attribute that to auto-completion and the ability to debug remotely; seldom ever leaving the IDE.

Completely worth the investment!
Thank you Paul!
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 08, 2014, 01:32:09 am
@aechelon, thank you for the flattering review. I'm glad you are enjoying the product! Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 24, 2014, 01:49:24 pm
ZeroBrane Studio for Vera v0.50 has been released (http://forum.micasaverde.com/index.php/topic,24200.0.html); this new version should address all the issues that have been discussed in this thread. See the linked forum post for details.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: drewcovi on March 29, 2014, 04:12:58 pm
3. If nothing else works, it's possible that the debugger component was not correctly set on the device. You can reset the saved configuration and try to set the debugger again, which may resolve this issue. Run the following command from the Local console in ZBS (just replace 35......22 with the full number of your device):

(function() local s = ide.packages.vera:GetSettings(); s['35....22'] = nil; ide.packages.vera:SetSettings(s) end)()

How can I find my device number?  I'm basically getting the exact same issue.

Code: [Select]
Trying to detect Vera device address from mios.com...
Connecting to Vera device at 10.0.1.19:3480...
Using '127.0.0.1' as the debugger server address.
Debugger server started at localhost:8172.
Program starting as '"/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua" -e "loadstring(require('mime').unb64('G0xKAQCdBGxvY2FsIHMgPSByZXF1aXJlKCdzb2NrZXQnKSBsb2NhbCBjID0gcy50Y3AoKSBjOnNldHRpbWVvdXQoMykgZnVuY3Rpb24gY2hlY2sob2ssIGVycikgaWYgbm90IG9rIHRoZW4gcHJpbnQoZXJyKTsgb3MuZXhpdCgpIGVuZCBlbmQgY2hlY2soYzpjb25uZWN0KCcxMC4wLjEuMTknLCAzNDgwKSkgY2hlY2soYzpzZW5kKFtbR0VUIC9kYXRhX3JlcXVlc3Q/aWQ9bHVfYWN0aW9uJnNlcnZpY2VJZD11cm46bWljYXNhdmVyZGUtY29tOnNlcnZpY2VJZDpIb21lQXV0b21hdGlvbkdhdGV3YXkxJmFjdGlvbj1SdW5MdWEmQ29kZT1yZXF1aXJlKCdtb2JkZWJ1ZycpLmxvb3AoJzEyNy4wLjAuMScsODE3Mik7cmVxdWlyZSgnbW9iZGVidWcnKS5kb25lKCkgSFRUUC8xLjFdXS4uJ1xuXG4nKSkgYzpzZXR0aW1lb3V0KG5pbCkgbG9jYWwgbGluZSwgZXJyID0gYzpyZWNlaXZlKCkgaWYgbm90IChsaW5lIGFuZCBsaW5lOmZpbmQoJzIwMCBPSycpKSB0aGVuIHByaW50KGVycikgZWxzZSBwcmludChsaW5lLi4nXG4nLi5jOnJlY2VpdmUoJyphJykpIGVuZCBjOmNsb3NlKClRAAIEAAMACRUBAA4AAABUAgaANAIAABADAQA+AgIBNAIBADcCAgI+AgEBRwABAAlleGl0B29zCnByaW50AAAAAAAAAAAAb2sAAAplcnIAAAoA5wQDAAoAEgA6UAABNAAAACUBAQA+AAICNwECAD4BAQIQAwEANwIDAScEAwA+AgMBMQIEADUCBQA0AgUAEAQBADcDBgElBQcAJwaYDT4DBAA9AgABNAIFABAEAQA3AwgBJQUJACUGCgAkBQYFPgMDAD0CAAEQAwEANwIDASkEAAA+AgMBEAMBADcCCwE+AgIDDwACAFQEBoAQBQIANwQMAiUGDQA+BAMCDgAEAFQEBIA0BA4AEAUDAD4EAgFUBAmANAQOABAFAgAlBg8AEAgBADcHCwElCRAAPgcDAiQFBwU+BAIBEAUBADcEEQE+BAIBRwABAApjbG9zZQcqYQYKCnByaW50CzIwMCBPSwlmaW5kDHJlY2VpdmUHCgrEAUdFVCAvZGF0YV9yZXF1ZXN0P2lkPWx1X2FjdGlvbiZzZXJ2aWNlSWQ9dXJuOm1pY2FzYXZlcmRlLWNvbTpzZXJ2aWNlSWQ6SG9tZUF1dG9tYXRpb25HYXRld2F5MSZhY3Rpb249UnVuTHVhJkNvZGU9cmVxdWlyZSgnbW9iZGVidWcnKS5sb29wKCcxMjcuMC4wLjEnLDgxNzIpO3JlcXVpcmUoJ21vYmRlYnVnJykuZG9uZSgpIEhUVFAvMS4xCXNlbmQOMTAuMC4xLjE5DGNvbm5lY3QKY2hlY2sAD3NldHRpbWVvdXQIdGNwC3NvY2tldAxyZXF1aXJlAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAXMABDdjAAI1bGluZQAcGWVycgAAGQAA'))()"'.
Program 'lua' started in '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/myprograms' (pid: 10891).
Program completed in 0.03 seconds (pid: 10891).
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 29, 2014, 05:29:33 pm
> How can I find my device number?  I'm basically getting the exact same issue.

@drewcovi, you can probably see the device number when you login to your device. For example, in my case the prompt is "root@MiOS_3xxxxxx1:~#". You'll need to use that 3xxxxxx1 number.

What version of ZeroBrane Studio are you using? You can see the version number if you go to `Help | About` menu. If you are already using v0.50, I don't think resetting the debugger would help you as it has to happen automatically. More likely, it's the IP address of the computer running the IDE that is not being identified correctly:

> Connecting to Vera device at 10.0.1.19:3480...
> Using '127.0.0.1' as the debugger server address.

Note that ZBS detected the local IP address as 127.0.0.1, which is probably not the right address to use from the device running on 10.0.1.19. If you know the right IP address for the computer running the IDE, you can set it manually by going to `Edit | Preferences | Settings: User` and adding the following line there:

debugger.hostname = "10.0.1.whatever" --<-- replace this with IP address of the computer running ZBS

and restarting ZBS. You should then see this address reported in the Output window as part of the "Using '10.0.1.whatever' as the debugger server address." message. Please let me know if this resolved the issue.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: drewcovi on March 29, 2014, 06:15:05 pm
Hmmmm darn. I tried to set it actually before hand (having reviewed this thread) but got nothing (mine was 10.0.1.9)

here's some output using my machine name.  I have also tested this with the network utility and when it pings the port number, ZBS does react (although gives an error because its null)

Code: [Select]
Trying to detect Vera device address from mios.com...
Connecting to Vera device at 10.0.1.19:3480...
Using 'drews-macbook-air.local' as the debugger server address.
Debugger server started at drews-macbook-air.local:8172.
Program starting as '"/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua" -e "loadstring(require('mime').unb64('G0xKAQCrBGxvY2FsIHMgPSByZXF1aXJlKCdzb2NrZXQnKSBsb2NhbCBjID0gcy50Y3AoKSBjOnNldHRpbWVvdXQoMykgZnVuY3Rpb24gY2hlY2sob2ssIGVycikgaWYgbm90IG9rIHRoZW4gcHJpbnQoZXJyKTsgb3MuZXhpdCgpIGVuZCBlbmQgY2hlY2soYzpjb25uZWN0KCcxMC4wLjEuMTknLCAzNDgwKSkgY2hlY2soYzpzZW5kKFtbR0VUIC9kYXRhX3JlcXVlc3Q/aWQ9bHVfYWN0aW9uJnNlcnZpY2VJZD11cm46bWljYXNhdmVyZGUtY29tOnNlcnZpY2VJZDpIb21lQXV0b21hdGlvbkdhdGV3YXkxJmFjdGlvbj1SdW5MdWEmQ29kZT1yZXF1aXJlKCdtb2JkZWJ1ZycpLmxvb3AoJ2RyZXdzLW1hY2Jvb2stYWlyLmxvY2FsJyw4MTcyKTtyZXF1aXJlKCdtb2JkZWJ1ZycpLmRvbmUoKSBIVFRQLzEuMV1dLi4nXG5cbicpKSBjOnNldHRpbWVvdXQobmlsKSBsb2NhbCBsaW5lLCBlcnIgPSBjOnJlY2VpdmUoKSBpZiBub3QgKGxpbmUgYW5kIGxpbmU6ZmluZCgnMjAwIE9LJykpIHRoZW4gcHJpbnQoZXJyKSBlbHNlIHByaW50KGxpbmUuLidcbicuLmM6cmVjZWl2ZSgnKmEnKSkgZW5kIGM6Y2xvc2UoKVEAAgQAAwAJFQEADgAAAFQCBoA0AgAAEAMBAD4CAgE0AgEANwICAj4CAQFHAAEACWV4aXQHb3MKcHJpbnQAAAAAAAAAAABvawAACmVycgAACgD1BAMACgASADpQAAE0AAAAJQEBAD4AAgI3AQIAPgEBAhADAQA3AgMBJwQDAD4CAwExAgQANQIFADQCBQAQBAEANwMGASUFBwAnBpgNPgMEAD0CAAE0AgUAEAQBADcDCAElBQkAJQYKACQFBgU+AwMAPQIAARADAQA3AgMBKQQAAD4CAwEQAwEANwILAT4CAgMPAAIAVAQGgBAFAgA3BAwCJQYNAD4EAwIOAAQAVAQEgDQEDgAQBQMAPgQCAVQECYA0BA4AEAUCACUGDwAQCAEANwcLASUJEAA+BwMCJAUHBT4EAgEQBQEANwQRAT4EAgFHAAEACmNsb3NlByphBgoKcHJpbnQLMjAwIE9LCWZpbmQMcmVjZWl2ZQcKCtIBR0VUIC9kYXRhX3JlcXVlc3Q/aWQ9bHVfYWN0aW9uJnNlcnZpY2VJZD11cm46bWljYXNhdmVyZGUtY29tOnNlcnZpY2VJZDpIb21lQXV0b21hdGlvbkdhdGV3YXkxJmFjdGlvbj1SdW5MdWEmQ29kZT1yZXF1aXJlKCdtb2JkZWJ1ZycpLmxvb3AoJ2RyZXdzLW1hY2Jvb2stYWlyLmxvY2FsJyw4MTcyKTtyZXF1aXJlKCdtb2JkZWJ1ZycpLmRvbmUoKSBIVFRQLzEuMQlzZW5kDjEwLjAuMS4xOQxjb25uZWN0CmNoZWNrAA9zZXR0aW1lb3V0CHRjcAtzb2NrZXQMcmVxdWlyZQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQFzAAQ3YwACNWxpbmUAHBllcnIAABkAAA=='))()"'.
Program 'lua' started in '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/myprograms' (pid: 12410).
Program completed in 0.03 seconds (pid: 12410).

He'res what I get from a basic ping on that port.
Code: [Select]
Debugger sent (command): basedir /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/myprograms/
Can't start debugging session due to internal error 'lualibs/mobdebug/mobdebug.lua:1353: bad argument #1 to 'find' (string expected, got nil)'.
Debugger sent (command): exit
Program finished
Debugger received (file, line, err): nil nil nil
Debugging session completed (traced 0 instructions).

Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 29, 2014, 07:25:27 pm
> Hmmmm darn. I tried to set it actually before hand (having reviewed this thread) but got nothing (mine was 10.0.1.9)

> Debugger server started at drews-macbook-air.local:8172.

@drewcovi, are you saying you tried setting "debugger.hostname" to "10.0.1.9" with the same result? Because in the output you are showing it appears to be set to "drews-macbook-air.local". Are you sure this domain name is accessible from the Vera device?

> He'res what I get from a basic ping on that port.

That looks normal as the debugger gets your ping and tries to respond with "basedir" command, which you don't respond to, hence the error message you get.'

It does look strange that you don't get any connection to the debugger. When it's successful, you should see "Debugging session started in ...." message in the Output window. The fact that it doesn't happen points to ether something standing between the device and the OSX machine running the IDE or that the address of the IDE is still incorrect.

When you try the ping on that debug port, do you do it locally or from the Vera device? Can you login to the Vera box and do a ping on that port from Vera?
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: drewcovi on March 29, 2014, 07:52:27 pm
I tried to ping the machine-name and it didnt work from the vera, so I changed the config back to the IP address...

unfortunately the results are similar if not the same.

Code: [Select]
Trying to detect Vera device address from mios.com...
Connecting to Vera device at 10.0.1.19:3480...
Using '10.0.1.9' as the debugger server address.
Debugger server started at 10.0.1.9:8172.
Program starting as '"/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua" -e "loadstring(require('mime').unb64('G0xKAQCcBGxvY2FsIHMgPSByZXF1aXJlKCdzb2NrZXQnKSBsb2NhbCBjID0gcy50Y3AoKSBjOnNldHRpbWVvdXQoMykgZnVuY3Rpb24gY2hlY2sob2ssIGVycikgaWYgbm90IG9rIHRoZW4gcHJpbnQoZXJyKTsgb3MuZXhpdCgpIGVuZCBlbmQgY2hlY2soYzpjb25uZWN0KCcxMC4wLjEuMTknLCAzNDgwKSkgY2hlY2soYzpzZW5kKFtbR0VUIC9kYXRhX3JlcXVlc3Q/aWQ9bHVfYWN0aW9uJnNlcnZpY2VJZD11cm46bWljYXNhdmVyZGUtY29tOnNlcnZpY2VJZDpIb21lQXV0b21hdGlvbkdhdGV3YXkxJmFjdGlvbj1SdW5MdWEmQ29kZT1yZXF1aXJlKCdtb2JkZWJ1ZycpLmxvb3AoJzEwLjAuMS45Jyw4MTcyKTtyZXF1aXJlKCdtb2JkZWJ1ZycpLmRvbmUoKSBIVFRQLzEuMV1dLi4nXG5cbicpKSBjOnNldHRpbWVvdXQobmlsKSBsb2NhbCBsaW5lLCBlcnIgPSBjOnJlY2VpdmUoKSBpZiBub3QgKGxpbmUgYW5kIGxpbmU6ZmluZCgnMjAwIE9LJykpIHRoZW4gcHJpbnQoZXJyKSBlbHNlIHByaW50KGxpbmUuLidcbicuLmM6cmVjZWl2ZSgnKmEnKSkgZW5kIGM6Y2xvc2UoKVEAAgQAAwAJFQEADgAAAFQCBoA0AgAAEAMBAD4CAgE0AgEANwICAj4CAQFHAAEACWV4aXQHb3MKcHJpbnQAAAAAAAAAAABvawAACmVycgAACgDmBAMACgASADpQAAE0AAAAJQEBAD4AAgI3AQIAPgEBAhADAQA3AgMBJwQDAD4CAwExAgQANQIFADQCBQAQBAEANwMGASUFBwAnBpgNPgMEAD0CAAE0AgUAEAQBADcDCAElBQkAJQYKACQFBgU+AwMAPQIAARADAQA3AgMBKQQAAD4CAwEQAwEANwILAT4CAgMPAAIAVAQGgBAFAgA3BAwCJQYNAD4EAwIOAAQAVAQEgDQEDgAQBQMAPgQCAVQECYA0BA4AEAUCACUGDwAQCAEANwcLASUJEAA+BwMCJAUHBT4EAgEQBQEANwQRAT4EAgFHAAEACmNsb3NlByphBgoKcHJpbnQLMjAwIE9LCWZpbmQMcmVjZWl2ZQcKCsMBR0VUIC9kYXRhX3JlcXVlc3Q/aWQ9bHVfYWN0aW9uJnNlcnZpY2VJZD11cm46bWljYXNhdmVyZGUtY29tOnNlcnZpY2VJZDpIb21lQXV0b21hdGlvbkdhdGV3YXkxJmFjdGlvbj1SdW5MdWEmQ29kZT1yZXF1aXJlKCdtb2JkZWJ1ZycpLmxvb3AoJzEwLjAuMS45Jyw4MTcyKTtyZXF1aXJlKCdtb2JkZWJ1ZycpLmRvbmUoKSBIVFRQLzEuMQlzZW5kDjEwLjAuMS4xOQxjb25uZWN0CmNoZWNrAA9zZXR0aW1lb3V0CHRjcAtzb2NrZXQMcmVxdWlyZQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQFzAAQ3YwACNWxpbmUAHBllcnIAABkAAA=='))()"'.
Program 'lua' started in '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/myprograms' (pid: 13068).
Program completed in 0.03 seconds (pid: 13068).
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on March 29, 2014, 08:20:27 pm
> I tried to ping the machine-name and it didnt work from the vera, so I changed the config back to the IP address...

I assume you can ping 10.1.1.9 address from the Vera device, right?

> unfortunately the results are similar if not the same.

Can you email me at support@zerobrane.com as I get 30m delay in notifications from the forum? It may be better to resolve this over email or IRC. Thank you. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: SOlivas on April 24, 2014, 09:58:35 am
(Sorry for chiming in so late)

ZBS is great for those who want to create plugins for Vera and have a way to help debug the problems/errors that you will encounter.

Before using ZBS, I programmed all my plugins in Notepad+ and debugged them sending messages to Vera's logging function (while watching the output using a terminal).  While it works, it is a pain.

Like RTS said, there is a nice learning curve with Lua, and you also have one when learning how to create plugins for Vera.  You will have to go through a lot of trial and error.  ZBS is great for helping make the process a bit less annoying.

Just my 2 cents.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: Stuart on July 08, 2014, 04:17:14 pm
@Paul

Was using LfW - not bad as I had put together a test harness to mimic the Luup functions I needed.  With google v3 api's looming I will need to handle OAuth2 in my plugin (goggle calendar II).  The to and fro to vera was a pain (especially when I forgot to change XML sensitive portions).

Decided to try Zerobrane and am immediately impressed - especially at my sloppy code (thanks to Analyse).

I can see that getting OAuth2 working will be easier executing on the vera.  So I'm willing to take the plunge to the vera version.  Two questions:
1) forgive as I have not read the entire forum .....  Does this allow debugging to a remote vera ?  I'm typically several routers and a WAN away
2) Could you PM PayPal details if the answer to (1) is positive.  I like to keep my Credit Card info 'footprint' to a minimum.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on July 08, 2014, 07:34:13 pm
@Stuart,

> 1) forgive as I have not read the entire forum .....  Does this allow debugging to a remote vera ?  I'm typically several routers and a WAN away

Yes, as long as you can establish a connection from the vera back to your computer running the IDE. If you run into any problems, let me know and I'll work with you to find a solution.

> 2) Could you PM PayPal details if the answer to (1) is positive.  I like to keep my Credit Card info 'footprint' to a minimum.

Understood, although I'm not storing the CC information and neither is Stripe (which I'm using for CC processing). I'm sending you PayPal details via PM. Thank you!

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: rollertrol on July 10, 2014, 11:01:43 am
Hi All, just wanted to mention that I purchased ZeroBrane yesterday, and I was able to create and execute the program I needed in the first 5 minutes of use. I have (had) zero knowledge of the Lua programming knowledge.

I have been programming computers for about 35 years and I don't think I have ever seen an environment that is easier to get started with. It is a rare occasion to see 'no brainer' software developed like this, where no assumptions were made about the newbie's skill level (or lack thereof).

Cheers, Adrian
RollerTrol Automation Systems
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: mano on July 31, 2014, 03:51:32 pm
Paul,
 Read it somewhere, if I have 2 vera boxes, one at 192.168.0.102 and the other at 192.168.0.103, How do I force/specify  the IDE to use 103.
Mano
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on July 31, 2014, 04:15:23 pm
Read it somewhere, if I have 2 vera boxes, one at 192.168.0.102 and the other at 192.168.0.103, How do I force/specify  the IDE to use 103.

Mano, when you run your script or start a debugging session from the IDE and it detects you have multiple devices, you will get a prompt to select a particular device you want to work with. All the subsequent debugging and interactions will be done with that device. You won?t be asked again until you restart ZeroBrane Studio.

If you only work with one device and don't want to see the dialog, you can explicitly configure ZBS to use that device by adding to the configuration file (Edit | Preferences | Settings: User)

path.vera = '192.168.0.103'

Make sure to restart ZBS after changing the settings. I've added this to the FAQ.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: mano on July 31, 2014, 04:29:16 pm
Paul,
Did not get an option for selection of multiple devices.
Added the path.vera to User settings and after close and re-open ZBS it goes to the correct unit.
Tks
Mano

Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on July 31, 2014, 04:39:19 pm
Did not get an option for selection of multiple devices.
Added the path.vera to User settings and after close and re-open ZBS it goes to the correct unit.

Mano, thank you for the update. The selection of devices is done based on the results returned by http://cp.mios.com/firmware/detect_unit.php (if there is more than one device reported). I'm curious to see why it's not working in your case. Can you PM me the response returned from that URL? Maybe there is only one device listed (for example, the one you used last)? Thank you.

Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: mano on July 31, 2014, 05:05:02 pm
Paul,
PM sent, strangely on the command only one of the unit shows as...  (edited for general info..)

[{"FK_AccessPoint":"301ZZZZZZZ","InternalIP":"192.168.0.102","AliveDate":"2014-07-31 13:27:47","MACAddress":"00:0X:XX:84:XX:XX","ForceUpgradeVersion":null,"ForceUpgradeUrl":null,"UpgradeInProgress":"0"}]

Where as getVera shows 2 when you use the control/Remote Access, in text format..

-----------------------------------------------------
Mano (301XXXXXX)  [ Rename ]

Serial #301XXXXX// IP: 192.168.0.102 [ Dashboard ]
-----------------------------------------------------
VeraPlay (351XXXXX)  [ Rename ]

Serial #351XXXXX // IP: 192.168.0.103 [ Dashboard ]
-----------------------------------------------------
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on July 31, 2014, 05:29:55 pm
PM sent, strangely on the command only one of the unit shows as...  (edited for general info..)

Yes, that's why ZBS doesn't give you the option to select the unit as it only sees one. I'm not sure how that data is populated on the MCV side, but the manual configuration you applied bypasses that check, so you should be good with the current configuration. Paul.
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: mano on July 31, 2014, 05:47:34 pm
Paul,
 Thanks, I'll check on the command few days time. The 2nd unit was a shop soiled unit, may be left over debris in MCV causing the issue.
Mano
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: paulclinger on January 14, 2015, 05:25:28 pm
The new version of ZBS for Vera (0.90) has been released. See this topic for details: http://forum.micasaverde.com/index.php/topic,30049.0.html
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: fouclo62 on April 18, 2015, 08:36:42 pm
Hi,

Not sure what is going on... I have been enjoying ZeroBrane for a few weeks and all was working fine since day one until today. 

Now every time ZeroBrane encounters a LUUP command it gives me an error (for example, when I run (debug or execute) the little program below)
1.   print("Hello")
2.   luup.log("World")
Code: [Select]
Program starting as '"C:\Program Files\ZeroBraneStudioVera-0.90-win32\bin\lua.exe" -e "io.stdout:setvbuf('no')" "C:\Users\Claude\AppData\Local\Temp\.9C30.tmp"'.
Program 'lua.exe' started in 'C:\Program Files\ZeroBraneStudioVera-0.90-win32\myprograms' (pid: 5924).
Debugging session started in 'C:\Program Files\ZeroBraneStudioVera-0.90-win32\myprograms\'.
Hello
ztest.lua:2: attempt to index global 'luup' (a nil value)
stack traceback:
ztest.lua: in main chunk
Debugging session completed (traced 1 instruction).
Program completed in 3.02 seconds (pid: 5924).
I reloaded my vera3,  rebooted my vera3,  even rebooted my computer, but no luck.  I did notice a message when I first started ZeroBrane today;  my Windows7 firewall gave me a warning that ZeroBrane was attempting to access the internet, to which I clicked "allow".  Also, during my numerous attempts of rebooting and what not,  I also at one point completely disabled my firewall for a while but it didn't change anything.

I am currently running the ZeroBrane Studio (0.90; MobDebug 0.607)  Built with wxWidgets 2.9.5

I have been reading the various forums here and on ZeroBrane website but to no avail.  I guess I do have a good connection to my vera because when I type the command:
Code: [Select]
require('socket.http').request('http://192.168.1.222/cgi-bin/cmh/online_check.sh?tmp=1'):match('"PK_AccessPoint":"(.+)"')... in the ZeroBrane console, it returns my Vera3-number.

Can you help please
Thx
Claude
Title: Re: ZeroBrane Studio for Vera -- Lua IDE for debugging on Vera devices
Post by: fouclo62 on April 18, 2015, 09:49:49 pm
Ok never mind... found it.

Somehow,  my Project interpreter had been reset to Lua (I have no clue how it happened... I certainly did not change this manually myself). 

So all I had to do was to set it back to Vera.

Now at least I can execute "LUUP" programs...  The debugger doesn't work anymore but I'm pretty sure I read plenty of other posts of other people that had a "debugger" problem so I will reread the thread and probably figure it out.

Thx
Claude