I am having a hard time to just use the SetDate function correctly. I look in the tstcallf.lua for example but did not get it.
Did you not understand it, or did it not work ? If you want help, you will get much better results if you give us a few more details.
To call event procs, you need to be using a build of CHDK that supports "native calls". This is off by default in the CHDK autobuilds. You can build your own (using whims chdkshell for example
http://chdk.setepontos.com/index.php?topic=845.0 ), or use chdkde, which has it enabled by default.
See also
http://chdk.wikia.com/wiki/Lua/Lua_Reference/Native_Function_CallsCan you please give me an example how to call it?
Again, it's not clear what you are asking. testcalf.lua shows you how to call event procs. The exact parameters required by SetDate need to be found by disassembling the firmware or experiment. It looks like it expects an array of 6 ints, which would correspond to year, month, day, hour, minute, second although not necessarily in that order.
Eventprocs are just C functions. From lua, you can can only pass a string or number, so to pass a C array, you need to create it using AllocateMemory and poke, and pass the pointer as a lua number. Don't forget to free it when you are done. tstcallf has an example of this, although the wrappers to record test results make it a bit convoluted.
To call SetDate as an event proc, you need to figure out what sequence of eventprocs is needed to register it. Generally, a return value of -1 from an eventproc means it wasn't registered, although of course there is no way to tell this from a registered function that happens to return -1.
On a540 (and later cameras by the looks of it) InitializeAdjustmentFunction registers this function. Alternatively, if you are only using one or two camera/firmware versions, you can just figure out the address of the functions from the dump and call directly with call_func_ptr.
edit:
I wasn't able to get SetDate to work, but
call_event_proc('InitializeAdjustmentFunction')
call_event_proc('SetHour',19)
call_event_proc('SetMinute',01)
worked as expected.
edit:
These functions call SetDate under the hood, so I must have done something wrong with the parameters.