PropertyCase Backup / Restore - Script Writing - CHDK Forum

PropertyCase Backup / Restore

  • 12 Replies
  • 6799 Views
PropertyCase Backup / Restore
« on: 20 / August / 2011, 03:39:26 »
Advertisements
is it possible to write a script to backup and restore the whole set of PropertyCase set

actually i want to save the state of my camera and then restore it as a default setting - i am particularly intrested in saving the custom white balance but saving restoring multiple properties like a profile would be very convenient.

i may be wrong but i did see a script posted on these line a while back(however i may be mistaken). but at that time was not intrested. ive been searching for some time but cant locate it.

is there such a script posted - if so pls help me locate it.
if not can someone tell me if it is not a stupid idea and will it work (with particular emphasis on the custom wb)

thanks

Re: PropertyCase Backup / Restore
« Reply #1 on: 20 / August / 2011, 11:51:19 »
is it possible to write a script to backup and restore the whole set of PropertyCase set
I believe you can read all PropertyCase values supported by CHDK on your camera but can only set some of them.

Quote
actually i want to save the state of my camera and then restore it as a default setting - i am particularly intrested in saving the custom white balance but saving restoring multiple properties like a profile would be very convenient.

i may be wrong but i did see a script posted on these line a while back(however i may be mistaken). but at that time was not intrested. ive been searching for some time but cant locate it.

is there such a script posted - if so pls help me locate it.
if not can someone tell me if it is not a stupid idea and will it work (with particular emphasis on the custom wb)
Somebody else had the same idea -
http://chdk.setepontos.com/index.php?topic=5736.msg56119#msg56119
but did not figure out the file I/O part of it.  I did a brief search through the wiki for uBasic or Lua info on reading and writing data to files.  It looks like Lua should be able to do it but I came up blank on uBasic.   When I get a minute I'll look some more - once we have that, the script should be easy to write.  Meanwhile I'm posting this in case someone already has an example of file I/O - saving me the trouble of working it out for myself.   :)
Ported :   A1200    SD940   G10    Powershot N    G16

Re: PropertyCase Backup / Restore
« Reply #2 on: 20 / August / 2011, 16:44:07 »
In SDM, if you enter a certain distance (!) in one of the menus the propcases are saved to a file on half-press

Code: [Select]
void save_prop_ids()
{
#if 0
int i,fd;
static char mybuf[80];
char *p = mybuf;
static int filenum = 1;
static struct utimbuf t;
t.actime = t.modtime = time(NULL);
sprintf(dir,"A/CHDK/PROP_ID");            // in DCIM/SDM
mkdir(dir);
sprintf(fn, "%s/", dir);
sprintf(fn+strlen(fn),"PROP%03d.txt",filenum);
 fd = open(fn, O_WRONLY|O_CREAT, 0777);  // create file and open it
 
 if (fd>=0)                              // if created and opened OK
  {

    for(i=0;i<301;i++)                   // for prop cases 0 to 300
       {
        sprintf(mybuf,"                ");       // clear buffer
        sprintf(mybuf,"%3d %11d\n",i,shooting_get_prop(i));     // get property case
        write(fd,mybuf,16);                               // write to file
       }
       close(fd);                        // close file
       filenum++;                   
  }
 #endif
}

Re: PropertyCase Backup / Restore
« Reply #3 on: 20 / August / 2011, 16:50:43 »
In SDM, if you enter a certain distance (!) in one of the menus the propcases are saved to a file on half-press
Interesting - is the "certain distance" a secret password or something?

Regardless, this C code needs to be compiled in and so is not overly useful if you are trying to implement this in a LUA or uBasic script.  Adding a built-in function to CHDK to save and restore PropertyCase values, activated from a menu, would be trival actually.  Is there a way to restore the saved values with SDM ?


« Last Edit: 20 / August / 2011, 16:53:42 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 14080
Re: PropertyCase Backup / Restore
« Reply #4 on: 20 / August / 2011, 17:01:22 »
Note that property cases are not all the same size. Some of them are many bytes long, so saving/restoring only a short or int worth could have unexpected side effects.

The behavior of propcases also dependent on the camera state (e.g. some only take effect at a certain point in the shooting process), so blindly saving/restoring them may not have the desired effect.

I did once write some tools to try to harvest all the propcase IDs and sizes from the firmware, but it's quite complicated because there are actually a lot of different propcase functions.
See here: http://chdk.setepontos.com/index.php?topic=2722.0

I'll try to find the files and re-up them, they were on drop.io :(
Don't forget what the H stands for.

Re: PropertyCase Backup / Restore
« Reply #5 on: 20 / August / 2011, 17:05:01 »
is the "certain distance" a secret password or something?


Yes, it means that it is not a menu option but you can debug if a user has problems.


*

Offline reyalp

  • ******
  • 14080
Re: PropertyCase Backup / Restore
« Reply #6 on: 20 / August / 2011, 17:07:10 »
See also propterycase dump and compare scripts/code linked here http://chdk.wikia.com/wiki/PropertyCase
Don't forget what the H stands for.

Re: PropertyCase Backup / Restore
« Reply #7 on: 20 / August / 2011, 17:17:06 »
See also propterycase dump and compare scripts/code linked here http://chdk.wikia.com/wiki/PropertyCase
I found a couple of options to write stuff to a file - but nothing for reading it back.
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 14080
Re: PropertyCase Backup / Restore
« Reply #8 on: 20 / August / 2011, 17:33:40 »
See also propterycase dump and compare scripts/code linked here http://chdk.wikia.com/wiki/PropertyCase
I found a couple of options to write stuff to a file - but nothing for reading it back.

You could do this trivially from lua (just write the file as a lua table and then load it as lua code) but as I said, blindly resetting the propcases is likely to be a bad idea.

edit:
reading the OP more carefully... writing back selected propcases would be fine. However, to do the custom WB, you will need to modify the C code or use eventproc calls, because the lua set_prop only accepts ints. Really, get_prop and set_prop should be modified to accept an optional length argument.
« Last Edit: 20 / August / 2011, 17:38:25 by reyalp »
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: PropertyCase Backup / Restore
« Reply #9 on: 21 / August / 2011, 03:52:30 »
In case it isn't clear to the OP yet, I'll just say that restoring propcase values is not really the way to restore camera state for interactive shooting. Not because some are read-only, but because the camera user interface doesn't take commands from the procases even if modifying their values have the desired effect on the photos.

So, the display will not update with your new Tv, MF, WB settings etc, making it really hard to be sure what's happening. Also, a half press + release or a single shot could reset that (requiring constant propcase updates, not just a single script run at startup), and that behavior may depend on shooting mode (M, Tv, P, Auto).


 

Related Topics