Running Lua scripts under CHDKPTP? - page 2 - Script Writing - CHDK Forum supplierdeeply

Running Lua scripts under CHDKPTP?

  • 19 Replies
  • 12261 Views
*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Running Lua scripts under CHDKPTP?
« Reply #10 on: 28 / February / 2013, 16:05:32 »
Advertisements
Notepad++ with the plugin nppexec and chdkptp is a good combination to start a script from the editor. A batch file upload the script to the camera and executes it.

msl
CHDK-DE:  CHDK-DE links

Re: Running Lua scripts under CHDKPTP?
« Reply #11 on: 28 / February / 2013, 20:45:12 »
Type
Code: [Select]
lua loadfile('A/CHDK/SCRIPTS/hdr.lua')() in the bottom text box (my A810 gives an error if I omit the full path)
Click the Execute button

Just to close this out, what you should have typed in the bottom text box was

Code: [Select]
=loadfile('A/CHDK/SCRIPTS/HDR.LUA')()
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14080
Re: Running Lua scripts under CHDKPTP?
« Reply #12 on: 01 / March / 2013, 00:27:41 »
Just to close this out, what you should have typed in the bottom text box was

Code: [Select]
=loadfile('A/CHDK/SCRIPTS/HDR.LUA')()
A little more explanation. The major commands in chdkptp have a one letter shortcut and a full name.
luar is the same as =
lua is the same as .
Both send lua code to the camera to run, and either should have worked equally well in the above scenario. The difference is that luar (=) waits for the code to finish on the camera before returning control to chdkptp. lua (.) just starts the code and returns immediately.

FYI, you can also run lua code in chdkptp (on your PC, not sent to the camera). This is done using the exec (!) command.

help (h) gives you a full list of commands. help -v gives more detailed descriptions of each command.

The error
Quote
Attempting to perform arithmetic on global 'f' (a nil value).
Is probably due to not having set the global variables the script expects from the script menu. The @ commands used to define the menu parameters are ignored unless you run the script form the menu, so all the a-z variables will be undefined.

To set them over chdkptp, you could do something like
Code: [Select]
lua f=1;loadfile(''A/CHDK/SCRIPTS/HDR.LUA")()
Don't forget what the H stands for.

Re: Running Lua scripts under CHDKPTP?
« Reply #13 on: 01 / March / 2013, 07:35:04 »
A little more explanation.
Thanks - yet again - for that.

If I might make a suggestion?  A quick C&P of what you wrote here with a light edit would make a fine addition to your USAGE.TXT file for chdkptp.  I know most of its there in pieces but a section specifically on running scripts would be most helpful.

Every now and then I have a feeling that its time to do a "CHDKPTP for Dummies" wiki page.  Especailly now that liveview seems stable.  I have some ideas on how that might look but I usually try to sit down with a cold beer until the feeling goes away.   Do you have anything roughed out?


« Last Edit: 01 / March / 2013, 07:36:40 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 14080
Re: Running Lua scripts under CHDKPTP?
« Reply #14 on: 01 / March / 2013, 23:30:41 »
A quick C&P of what you wrote here with a light edit would make a fine addition to your USAGE.TXT file for chdkptp.
Good idea. I've added a section about running script files.

Quote
Every now and then I have a feeling that its time to do a "CHDKPTP for Dummies" wiki page.  Especailly now that liveview seems stable.  I have some ideas on how that might look but I usually try to sit down with a cold beer until the feeling goes away.   Do you have anything roughed out?
No I don't, but I have some things in mind for it. There's definitely a need for a more tutorial "here's how to do various common things" approach. I was planning to put the documentation on chdkptp assembla wiki https://www.assembla.com/spaces/chdkptp/wiki I think it's currently only editable by team members but that can be changed.

Don't forget what the H stands for.

Re: Running Lua scripts under CHDKPTP?
« Reply #15 on: 18 / August / 2013, 07:06:42 »
No I don't, but I have some things in mind for it. There's definitely a need for a more tutorial "here's how to do various common things" approach. I was planning to put the documentation on chdkptp assembla wiki https://www.assembla.com/spaces/chdkptp/wiki I think it's currently only editable by team members but that can be changed.

Hi reyalp, you appear to be a very busy guy !

but - in case I missed it somewhere else, I was wondering if you'd had a chance to put a "CHDKPTP for Dummies":haha tutorial together yet [in my case that description would suit 110%].

I've got to page 20 [or thereabouts] a few times at http://chdk.setepontos.com/index.php?topic=6231.0 but then the eyes start glazing over a little   ???

*

Offline reyalp

  • ******
  • 14080
Re: Running Lua scripts under CHDKPTP?
« Reply #16 on: 18 / August / 2013, 14:50:28 »
but - in case I missed it somewhere else, I was wondering if you'd had a chance to put a "CHDKPTP for Dummies":haha tutorial together yet [in my case that description would suit 110%].
Unfortunately I haven't. USAGE.TXT http://trac.assembla.com/chdkptp/browser/trunk/USAGE.TXT (also included in the zip) is probably as close as you can get.

I started this https://www.assembla.com/spaces/chdkptp/wiki/CLI_Quickstart but haven't had time to actually flesh it out yet. After that the next thing on my list is some kind of scripting/API guide.

When reading the dev thread, you may be better off starting at the end and going backwards, since the early parts discuss issues that were fixed or things that changed later. It's not a very way to learn about the tool though.

If you have specific questions, don't hesitate to ask.
Don't forget what the H stands for.

Re: Running Lua scripts under CHDKPTP?
« Reply #17 on: 21 / August / 2013, 14:07:28 »
I started this https://www.assembla.com/spaces/chdkptp/wiki/CLI_Quickstart but haven't had time to actually flesh it out yet. After that the next thing on my list is some kind of scripting/API guide.

When reading the dev thread, you may be better off starting at the end and going backwards, since the early parts discuss issues that were fixed or things that changed later. It's not a very way to learn about the tool though.

If you have specific questions, don't hesitate to ask.

Will do - appreciate your reply. I think it's probably just a matter of immersing oneself in the whole subject matter and maybe becoming familiar with a little oop into the bargain  :blink:


Re: Running Lua scripts under CHDKPTP?
« Reply #18 on: 19 / November / 2013, 07:52:29 »
Unfortunately I haven't. USAGE.TXT http://trac.assembla.com/chdkptp/browser/trunk/USAGE.TXT (also included in the zip) is probably as close as you can get. ... If you have specific questions, don't hesitate to ask.

Hello reyalp! I am figuring out how to extend the capabilities of CHDKPTP for multicam. Thanks for that fine piece of software!

I am an absolute beginner using CHDKPTP and I wonder if you could point me at some sources I should know? I have downloaded the source code of CHDKPTP, but then became aware that it is possible to configure the GUI with lua scripts.

Is there any documentation somewhere about that?

I figured out how your simplemulticam.lua works, and I am about to plan a system to remotely adjust my complete rig using this functionality.

The decision right now will be whether to build my own solution in visual studio or to configure chdkptp to my needs. What do you suggest?

Thanks a lot!
« Last Edit: 19 / November / 2013, 08:00:04 by Karmaschinken »

*

Offline reyalp

  • ******
  • 14080
Re: Running Lua scripts under CHDKPTP?
« Reply #19 on: 19 / November / 2013, 16:40:43 »
I am an absolute beginner using CHDKPTP and I wonder if you could point me at some sources I should know? I have downloaded the source code of CHDKPTP, but then became aware that it is possible to configure the GUI with lua scripts.

Is there any documentation somewhere about that?
Not outside of the source really.  I'm happy to answer questions here or on IRC.

I did start some documentation at https://www.assembla.com/spaces/chdkptp/wiki/Scripting_Guide

Except for some C code for dealing with live view images and things like that, the GUI is written entirely in Lua using IUP http://www.tecgraf.puc-rio.br/iup/ and CD http://www.tecgraf.puc-rio.br/cd/

So you can customize or completely replace the GUI just by editing the gui*.lua files, or adding your own files and calling them from the GUI code.

Quote
The decision right now will be whether to build my own solution in visual studio or to configure chdkptp to my needs. What do you suggest?
That depends on your needs and your preferences for languages and tools. Obviously if it were me, I would probably build something on chdkptp, but that doesn't mean it's right for you.

One issue with the current chdkptp code is that it is completely single threaded. That means that you can only transfer data from one camera at a time. You can have multiple active connections (as used in the multicam modules) but only one PTP API call to one camera can be running at a given time. In the current GUI code, the GUI is also completely blocked when a PTP call is in progress.

On the plus side, I find that being able to interactively run code in both the client and camera and send Lua values seamlessly between them is really great for development and testing.
Don't forget what the H stands for.

 

Related Topics