Run script file from CHDK - General Discussion and Assistance - CHDK Forum supplierdeeply

Run script file from CHDK

  • 21 Replies
  • 7877 Views
Run script file from CHDK
« on: 06 / December / 2011, 08:13:56 »
Advertisements
Updated version of this patch:

Patch with infrastructure to call script.
1. Increase isolation of mpopup from fileselector.
2. Extend script.c with infrastructure to temporary scripts call.
3. First integration sample to use that: integration lua script "editor" into fileselector (popup menu).

- Fixed important bug which cause shutdown on previous version on sequence: enter fselect - press "alt" - try to reenter to fselect
- rebased to 1457

Known issue: If close editor in same way, menu will hangup when we try to turn back to it. This problem exists in base 1457rev too.
« Last Edit: 07 / December / 2011, 04:12:16 by acseven »

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Run script file from CHDK
« Reply #1 on: 06 / December / 2011, 14:23:32 »
Updated version of this patch:

Patch with infrastructure to call script.
1. Increase isolation of mpopup from fileselector.
2. Extend script.c with infrastructure to temporary scripts call.
3. First integration sample to use that: integration lua script "editor" into fileselector (popup menu).

- Fixed important bug which cause shutdown on previous version on sequence: enter fselect - press "alt" - try to reenter to fselect
- rebased to 1457

Sorry, haven't had time to look at this yet. It's a significant change so will take some time to fully understand.

Quote
Known issue: If close editor in same way, menu will hangup when we try to turn back to it. This problem exists in base 1457rev too.

Can you explain the steps to cause this in more detail please - I can't get the current editor or file selector to hangup in build 1457.

Phil.
« Last Edit: 07 / December / 2011, 04:14:45 by acseven »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline reyalp

  • ******
  • 14072
Re: Run script file from CHDK
« Reply #2 on: 06 / December / 2011, 16:12:11 »
2. Extend script.c with infrastructure to temporary scripts call.
3. First integration sample to use that: integration lua script "editor" into fileselector (popup menu).
While this is a good idea and a useful feature, I'm not happy with the current implementation. The script param stuff is already a mess, and this takes it in the wrong direction. Hard coding specific scripts into the C code also strikes me as the wrong approach as does the hack for the file selector.

If you are interested in having this feature integrated, I'd suggest starting a new thread to discuss the implementation rather than just throwing patches at us.

I really don't like to reject useful work, but we are already at a point where the existing mess makes it extremely hard to implement new features safely and quickly.

If you can post your bug fixes separately from your new experimental features, that will make it a lot easier to get them integrated quickly.
« Last Edit: 07 / December / 2011, 04:14:56 by acseven »
Don't forget what the H stands for.

Re: Run script file from CHDK
« Reply #3 on: 06 / December / 2011, 16:20:56 »
If I might suggest something - It'd be good to discuss these file-selector-related changes in separated thread. This changes give us a lot of new possibilities including calling a script from file browser (I very like it) but are done in some strange way.

Especially I'm pretty sure that file selector have to end before script is loaded, since now there is no way to call it again from the script. I'm going to add to my editor a menu entry such as "save a copy..." and "write a new file" which requires to select a directory for the copy or the new file. And at the moment it's impossible if script is called from the file selector.

IMO the script should not be run as popup but as a regular script, and as it was run by shoot key. Maybe the only difference (from script POV) should be one more parameter (of command), for example get_menu_started(), just like we have get_autostarted().

So - who like to start new thread?

---- edit ---
@reyalp
Huh - the same things, the same time;)
« Last Edit: 07 / December / 2011, 04:15:02 by acseven »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: Run script file from CHDK
« Reply #4 on: 07 / December / 2011, 04:59:13 »
While this is a good idea and a useful feature, I'm not happy with the current implementation. The script param stuff is already a mess, and this takes it in the wrong direction. Hard coding specific scripts into the C code also strikes me as the wrong approach as does the hack for the file selector.
I do agree regarding to fileselector hack. Is this that you mean in "The script param stuff is already a mess, and this takes it in the wrong direction"?

Could you also explain please what do you mean "The script param stuff is already a mess, and this takes it in the wrong direction".

If you can post your bug fixes separately from your new experimental features, that will make it a lot easier to get them integrated quickly.
Bug fixes included into this patch was for my previous patch. In current trunk no such problem existed.

Re: Run script file from CHDK
« Reply #5 on: 07 / December / 2011, 05:03:21 »
If I might suggest something - It'd be good to discuss these file-selector-related changes in separated thread. This changes give us a lot of new possibilities including calling a script from file browser (I very like it) but are done in some strange way.
I thought that LUA is too hard to add something. And so I go into way of minimal impact on lua module and lua script.
I was wrong.

IMO the script should not be run as popup but as a regular script, and as it was run by shoot key. Maybe the only difference (from script POV) should be one more parameter (of command), for example get_menu_started(), just like we have get_autostarted().
I'm not sure what do you mean. Are you talking about fselect hack? or about idea of "temporarity" calls? or that runed script should be stay loaded after finish?

Re: Run script file from CHDK
« Reply #6 on: 07 / December / 2011, 05:18:01 »
In attachment rewrited version of this feature and fixed to use this version of EDITOR.lua.

How it works now:

1. Infrastructure of temporary call:
TO RUN SCRIPT:
  * temporary_script_load() store current script parameters (including it's path) into new kind of file "A/CHDK/DATA/paramset.old" using existed infrastructure of storing paramset
  * then it load requested script ("fn" parameter)
  * then it call "on_start" callback, where chdk could adjust any input parameters of script
  * then it run loaded script in common way

WHEN SCRIPT FINISHED:
  * "on_end" callback is called to make specific restore action. temporary_script_unload() should be called inside to automatic restore previous script w parameters
  * you could just specify temporary_script_unload as "on_end" callback if no specific action required
  * or you even give zero value of "on_end", then started script stay loaded

2. Infrastructure of string input parameters.
   * values are stored in the array of strings conf.script_str_vars. (1 strings for now)
   * to get string input parameter use new lua function get_param_str():
             string = get_param_str(idx_of_param)

So if you would like to give to LUA string input parameter you just need to copy string into this parameter and then get it in script. Because no way exist now to enter string in menu it is not displayed in scripting menu and not stored in config file.

upd: Patch was broken before attachment. Correct version at http://chdk.setepontos.com/index.php?topic=7227.msg77583#msg77583
« Last Edit: 07 / December / 2011, 09:13:58 by tsvstar »

Re: Run script file from CHDK
« Reply #7 on: 07 / December / 2011, 07:37:26 »
A... nice;)
From my POV that's all I need. I guess so, since I just looked in the code and I'm not really sure if it works as I think, but now I can get the file (or other) parameter from the script.

My question is: can I now run file_browser() from script if it was loaded from menu item? To get, for example, another file.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: Run script file from CHDK
« Reply #8 on: 07 / December / 2011, 07:58:05 »
My question is: can I now run file_browser() from script if it was loaded from menu item? To get, for example, another file.
Yes you could.
I did quick check right now and found that everything works ok, but for this case (second call editor) script is not correctly return on finish. I'll investigate this problem.

Re: Run script file from CHDK
« Reply #9 on: 07 / December / 2011, 08:50:58 »
Well, in fact the problem of incorrectly finished script was there before. Since file_browser() function is used something is wrong. The best way what is wrong is to describe the problem, so:

- you run script
- this script calls file_browser(), you select a file and then script do what it's designed to
- then you end the script (shoot_full or just end)
and then you like to call another script, maybe change params or something. So you press FUNC key. But instead of scripts menu, the file browser is immetiately run.

This problem appears only if you use file_browser() in a script.
« Last Edit: 07 / December / 2011, 08:55:58 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

 

Related Topics