alternative ways to start a script - General Discussion and Assistance - CHDK Forum

alternative ways to start a script

  • 30 Replies
  • 14158 Views
alternative ways to start a script
« on: 15 / November / 2013, 20:10:51 »
Advertisements
There have been several discussions over the last couple of years about alternative / additional methods to launch a script.  Amongst those considered were :

  • Launch script on a defined event (eg: change of camera mode) as suggested by tsvstar
  • Launch a script from the User Menu (instead of just selecting the current one) by me.
  • Rewrite the keyboard code to allow user defined button remapping - which could include tying a specified script to a particular button press ( maybe only in ALT mode) - by reyalp.

I'd like to (someday) have all of the above available.

But in the meantime, here's a small patch that lets you specify that the current script should run immediately when you enter <ALT>.   I think this is consistent with allowing the User Menu to be run "On Direct".  To enable the current script, an additional menu choice has been added to the Autostart menu item in the Script menu.

On exiting the script,  the camera is left in <ALT> mode so normal CHDK activity can take place.

This can be handy for setting up your favorite script to run with one button press.  I'm working on something now where this would be particularly handy !
« Last Edit: 15 / November / 2013, 20:15:45 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: alternative ways to start a script
« Reply #1 on: 17 / November / 2013, 11:16:23 »
The 'ALT start' idea is very good. I think every extra method to start a script is welcome.

However, the easiest way would be a start via user menu. But this is certainly a challenging task.

msl
CHDK-DE:  CHDK-DE links

Re: alternative ways to start a script
« Reply #2 on: 17 / November / 2013, 11:25:14 »
The 'ALT start' idea is very good. I think every extra method to start a script is welcome.
However, the easiest way would be a start via user menu. But this is certainly a challenging task.
Thanks for the post. 

I looked briefly at adding the User Menu option as well.  It different than my <ALT> key patch as it requires multiple key presses but does allow you to run different scripts quickly.

The easiest way to add this would be to convert the current script User Menu entry so that it runs rather than loads when Func/Set is pressed.   The other way is to add a different User Menu entry type that runs rather than selects.  Not sure how to make that work graphically so that you can tell one from the other - maybe prefix the script name on the menu items with either Load: or Run: ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14128
Re: alternative ways to start a script
« Reply #3 on: 23 / November / 2013, 21:00:30 »
I finally got a chance to look at this.

The behavior when you enter and leave the script menu seems a bit confusing. When you first set the auto start option to alt, the script starts when you leave the menu using the menu key. If you subsequently enter and exit the the script menu, it doesn't. Exiting the script menu via the alt key works as you'd expect, the script starts the next time you enter alt.

The other thing that concerns me is if a script changes the script abort key to something that doesn't work on the camera, the only way to get out of it would be deleting the script or cfg using a card reader, since you can no longer enter alt to change the setting. I guess this is true of autostart as well.

The whole thing feels a bit kludgy, but I admit I don't really have a better idea...
Don't forget what the H stands for.

Re: alternative ways to start a script
« Reply #4 on: 23 / November / 2013, 22:50:39 »
The behavior when you enter and leave the script menu seems a bit confusing. When you first set the auto start option to alt, the script starts when you leave the menu using the menu key. If you subsequently enter and exit the the script menu, it doesn't. Exiting the script menu via the alt key works as you'd expect, the script starts the next time you enter alt.
I can take a look at locking that out.

Quote
The other thing that concerns me is if a script changes the script abort key to something that doesn't work on the camera, the only way to get out of it would be deleting the script or cfg using a card reader, since you can no longer enter alt to change the setting. I guess this is true of autostart as well.
This might be a problem for the script author - but I thinks its a "let the coder be aware" situation.  There might be an occasion when someone releases a script that causes issues here - but it seems that would not be a common thing?

Quote
The whole thing feels a bit kludgy, but I admit I don't really have a better idea...
My goal ultimate goal here is to end up with basic CHDK functionality in a GUI mode without needing to wade through the menus.   I've started using scripts to do that .. we will just have to see where it ends up.
« Last Edit: 23 / November / 2013, 22:52:40 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: alternative ways to start a script
« Reply #5 on: 24 / November / 2013, 13:30:34 »
Startup bug noted above fixed.   In doing so, I believe that the code got a little tidier and more robust as a result of how it was fixed.

There is still a possible issue with a script being started on <ALT> entry and then overriding the exit key, disabling the title line, and setting the console to "OFF",  thereby leaving the user confused if the script dies somehow.

I suppose  "script starts on <ALT>" mode could flash up a warning text box or title line message of some sort  .. two seconds of something that says "CHDK Script Autostarted" in gross RED/YELLOW maybe? That way a user with a borked script would at least have some idea of where to start looking?  You could even have an "ABORT" key that was active during the message period. 
Ported :   A1200    SD940   G10    Powershot N    G16

Re: alternative ways to start a script
« Reply #6 on: 24 / November / 2013, 14:23:25 »
I prototyped a version of the above patch that also spits out a 1 second warning on the title line prior to starting a script on <ALT> entry.

Don't really like the concept much personally but I thought it was worth trying to see what people think.

Incidentally,  my download script to transfer CHDK to the SD card via ptp does not like this patch either - it forces the download to wait one second between modules while the warning message displays.  Are there other unintended things that happen with CHDKPTP and these patches?

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14128
Re: alternative ways to start a script
« Reply #7 on: 24 / November / 2013, 16:07:53 »
I prototyped a version of the above patch that also spits out a 1 second warning on the title line prior to starting a script on <ALT> entry.
I don't think this is really worth it.

Quote
Incidentally,  my download script to transfer CHDK to the SD card via ptp does not like this patch either - it forces the download to wait one second between modules while the warning message displays.  Are there other unintended things that happen with CHDKPTP and these patches?
I didn't see any with the non-warning version. PTP scripts implicitly enter alt mode when the script runs. I was initially worried this would auto-run the script, but it doesn't. I'm not clear if the fact it does the right thing for PTP scripts is by design or happy accident. I think it has to do with gui_activate_alt_mode seeing kibd_script_run and going directly to scriptGuiHandler

An explicit =enter_alt() over PTP does end up starting the alt script, but enter_alt(); sleep(1000) does not... I haven't tried non-ptp scripts that explicitly use enter_alt/exit_alt

Starting after an enter_alt() call is not desirable, especially over PTP where there isn't a way to kill the script cleanly without physically pressing buttons on the camera (hmm, I should really implement remote kill for 1.3...)
Quote
There is still a possible issue with a script being started on <ALT> entry and then overriding the exit key, disabling the title line, and setting the console to "OFF",  thereby leaving the user confused if the script dies somehow.
I'm not really worried about "malicious" scripts. My concern is if someone makes a script that is intended to run this way, but makes assumptions about keys that aren't present on a users camera. We have already had a number of cases where users accidentally enabled autostart and were confused about how to get out of it. I don't think we necessarily need to deal with this now, it gets us back to some earlier discussions about what alt mode and script mode actually mean.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: alternative ways to start a script
« Reply #8 on: 24 / November / 2013, 16:28:51 »
There is still a possible issue with a script being started on <ALT> entry and then overriding the exit key, disabling the title line, and setting the console to "OFF",  thereby leaving the user confused if the script dies somehow.

As reyalp pointed out, this is a potential issue now for autostart scripts, with the recent change to allow scripts to override the exit key.

We discussed it briefly on IRC yesterday, and one option suggested was to have a long press of the ALT button be a non-overridable script abort. This would only be active when a script was actually running. The disadvantage would be you could not use the Canon function behind the ALT button when a script was running (e.g. for cameras where the Playback button was mapped to ALT, you could not switch to playback mode while running a script).

Phil.
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

  • ******
  • 14128
Re: alternative ways to start a script
« Reply #9 on: 24 / November / 2013, 17:21:10 »
Trunk changeset 3247 adds this.

I made some changes:
* script_run_on_alt_flag is only set on keyboard entry to alt, rather than in enter_alt().  This should take care of the ptp issue and other possible issues with enter_alt() in script
* script_start values use #defines
* the script set_autostart functions include the new value in the range check.

Note, I'm not sure if/how this interacts with the touchscreen UI stuff?
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal