CHDK menus - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum

CHDK menus

  • 17 Replies
  • 368 Views
Re: CHDK menus
« Reply #10 on: 14 / February / 2019, 06:17:16 »
Advertisements
@reyalp

I've now stumbled on a limitation: I think.

I've managed to change by config file with this:

Code: [Select]
if e == 1 then
    os.remove("A/CHDK/LOGS/LOG_2306.TXT")
    print("Log File Deleted")
    local fp = io.open("A/CHDK/DATA/LBS.CFG")
    local str = fp:read("*all")
    fp:close()
    temp = string.sub(str, 1, 1)
    local con_fig = "A/CHDK/DATA/LBS."..temp
    fp = io.open (con_fig,"r")
    if fp == nil then
        return
    else
        str = fp:read("*all")
        fp:close()
        str = string.gsub(str,"#e=1","#e=0")
        fp = io.open (con_fig,"w")
        fp:write(str)
        fp:close()
        return -- exit script
    end
end

The issue is that this doesn't update the script details in CHDK, ie those in memory I guess. Thus when I go into the CHDK menu and into the Script sub menu, the script values I see are the 'old' values, ie not the updated config ones :-(

I wonder if you have any ideas? For example, allowing a script to 'force' CHDK to do a config refresh?
« Last Edit: 14 / February / 2019, 06:29:16 by pigeonhill »

Re: CHDK menus
« Reply #11 on: 14 / February / 2019, 07:28:05 »
OK: 'problem' has gone away for me as I worked out a palliative approach.

Code: [Select]
if e == 1 then
    local fp = io.open("A/CHDK/DATA/LBS.CFG")
    local str = fp:read("*all")
    fp:close()
    temp = string.sub(str, 1, 1)
    local con_fig = "A/CHDK/DATA/LBS."..temp
    fp = io.open (con_fig,"r")
    if fp == nil then
        print("No ConFig file found")
        return
    else
        str = fp:read("*all")
        fp:close()
        if string.find(str,"e=0") == nil then
            str = string.gsub(str,"#e=1","#e=0")
            fp = io.open (con_fig,"w")
            fp:write(str)
            fp:close()
            os.remove("A/CHDK/LOGS/LOG_2306.TXT")
            print("Log File Deleted")
            return -- exit script
        end
    end
end

Re: CHDK menus
« Reply #12 on: 14 / February / 2019, 09:27:56 »
The issue is that this doesn't update the script details in CHDK, ie those in memory I guess. Thus when I go into the CHDK menu and into the Script sub menu, the script values I see are the 'old' values, ie not the updated config ones :-( I wonder if you have any ideas? For example, allowing a script to 'force' CHDK to do a config refresh?
Reloading the script when you open the CHDK Menu should reload the user parameter values.  It's an extra step but does it work?

Otherwise you could hack the config.script_title variable to be null, which would cause the "No Script" situation, forcing you to reload the script from the menu.

Adding a script function that marks the user parameters "dirty" and forcing a reload when the Script Menu is drawn would be easy but is a code change. Automatically detecting that the parameter file had changed would be trickier. 

@reyalp - adding function to load or reload a particular set of script user parameters "on-the-fly" (there are 10 available) might be more interesting and useful for this and other application
`
OK: 'problem' has gone away for me as I worked out a palliative approach.
Did this caused the user parameters to reload or just change when your on screen messages are displayed?
« Last Edit: 14 / February / 2019, 09:38:24 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: CHDK menus
« Reply #13 on: 14 / February / 2019, 09:38:50 »
My palliative approach seems to work, which leads me to conclude that CHDK doesn’t update the script config file at the end of the script or at camera turn off.

If it did, my manual change to my script’s config changes would be overwritten by the unchanged script menu.

But I could be wrong ;-)


Re: CHDK menus
« Reply #14 on: 14 / February / 2019, 10:10:21 »
My palliative approach seems to work,
But that does not solve the issue of restarting the script (without a camera restart) and it still using the old parameters?

Quote
CHDK doesn’t update the script config file at the end of the script or at camera turn off.
That's correct AFAIK - script parameter values are only updated to the config file in response to changes made in the CHDK Menu.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: CHDK menus
« Reply #15 on: 14 / February / 2019, 10:22:54 »
@waterwingz

Quote
That's correct AFAIK - script parameter values are only updated to the config file in response to changes made in the CHDK Menu.

 :)

Thus, I'm happy with my 'palliative' approach  ;)

But still look forward to being able to 'interact' with CHDK script menu items.

Cheers

Garry

*

Offline reyalp

  • ******
  • 11747
Re: CHDK menus
« Reply #16 on: 14 / February / 2019, 16:32:43 »
My palliative approach seems to work, which leads me to conclude that CHDK doesn’t update the script config file at the end of the script or at camera turn off.
I don't understand what the "palliative approach" is. CHDK reads/writes the script config at some specific points (which I don't know off the top of my head without digging into the source) and I don't see how the differences in the quoted code would have any impact on it.

If it works for you, I guess that's fine, but I'd suggest there is some other factor at work.
Don't forget what the H stands for.

Re: CHDK menus
« Reply #17 on: 14 / February / 2019, 18:39:49 »
@reyalp

All I mean by the 'palliative approach' is my hack works for me. That is keeping track of the state of config file relative to the script's menu state.

It works because CHDK doesn't update the script's config file at the end of the script running or at camera switch off.

Once again thanks to you and @waterwingz for your help and insight.

Cheers

Garry


 

Related Topics