How to set date&time from fw? - DryOS Development - CHDK Forum supplierdeeply

How to set date&time from fw?

  • 12 Replies
  • 7181 Views
*

Offline alvm

  • ***
  • 123
How to set date&time from fw?
« on: 10 / October / 2015, 18:27:12 »
Advertisements
Hello,

I need to set date and time using ptp while menu "Set Date/Time" is on screen. So I use next code

_ExecuteEventProcedure("FA.Create");
_ExecuteEventProcedure("InitializeAdjustmentFunction");

_ExecuteEventProcedure("SetYear", 2015);
_ExecuteEventProcedure("SetMonth", 1);
_ExecuteEventProcedure("SetDay", 1);
_ExecuteEventProcedure("SetData");

The date is set fine but after power off/on menu "Set Date/Time" appears again. As I understand I need do some additional actions for complete the setting. So what kind of actions need to be done?

Thanks,
Alex.

*

Offline srsa_4c

  • ******
  • 4451
Re: How to set date&time from fw?
« Reply #1 on: 10 / October / 2015, 19:26:36 »
The date is set fine but after power off/on menu "Set Date/Time" appears again.
Question: do you switch off the camera by pressing the ON/OFF button (or the playback button), or you just switch off the power supply? The camera needs to be shut down properly for it to save the settings.

If you're shutting down the camera properly and still get the date/time screen, then close the dialog with 'OK' (not 'Cancel'). You can send keypress events to accomplish this. Once the dialog is closed, set date/time with your method and then shut down the camera properly.

For sending the events, see include/levent.h, core/levent.c, especially levent_post_to_ui_by_name(). You can of course simplify the code (using correct IDs directly) instead of implementing/copying the whole bunch of routines.

*

Offline alvm

  • ***
  • 123
Re: How to set date&time from fw?
« Reply #2 on: 11 / October / 2015, 13:01:55 »
Question: do you switch off the camera by pressing the ON/OFF button (or the playback button), or you just switch off the power supply? The camera needs to be shut down properly for it to save the settings.

I switch off the camera by pressing the ON/OFF button. The date after power OFF/ON is right, but the menu appears again.

*

Offline srsa_4c

  • ******
  • 4451
Re: How to set date&time from fw?
« Reply #3 on: 11 / October / 2015, 13:36:32 »
I switch off the camera by pressing the ON/OFF button. The date after power OFF/ON is right, but the menu appears again.
In that case, I'd recommend sending the keypress events to close the dialog properly. There's probably a flag that only gets set when that dialog is closed with OK.
The other possibility is to reverse engineer the code behind the date/time setting dialog. Something tells me that would be more difficult.


*

Offline alvm

  • ***
  • 123
Re: How to set date&time from fw?
« Reply #4 on: 11 / October / 2015, 13:41:03 »
Keypress events don't work while the menu on screen. If I switch camera to Rec mode (the menu disappears) the events work fine.

levent_post_to_ui_by_name("PressFuncButton");
msleep(400);
levent_post_to_ui_by_name("UnpressFuncButton");

PressSetButton & UnpressSetButton don't work too.
« Last Edit: 11 / October / 2015, 13:47:33 by alvm »

*

Offline srsa_4c

  • ******
  • 4451
Re: How to set date&time from fw?
« Reply #5 on: 11 / October / 2015, 13:46:24 »
Keypress events don't work while the menu on screen. If I switch camera to Rec mode (the menu disappears) the events work fine.
Forgot that you're using PTP. Try freeing up the buttons with levent 4484:
http://chdk.setepontos.com/index.php?topic=4338.msg64909#msg64909

*

Offline alvm

  • ***
  • 123
Re: How to set date&time from fw?
« Reply #6 on: 11 / October / 2015, 13:52:14 »
Works fine. Thanks!

*

Offline alvm

  • ***
  • 123
Re: How to set date&time from fw?
« Reply #7 on: 18 / November / 2015, 15:19:21 »
_ExecuteEventProcedure("InitializeAdjustmentFunction");

_ExecuteEventProcedure("SetYear", 2015);
...

works fine for sx170, but it cause for some wrong settings for sx160. sx160 hangs after shoot also. What kind of differences between these cameras in InitializeAdjustmentFunction proc event?


*

Offline srsa_4c

  • ******
  • 4451
Re: How to set date&time from fw?
« Reply #8 on: 18 / November / 2015, 19:49:31 »
_ExecuteEventProcedure("InitializeAdjustmentFunction");

_ExecuteEventProcedure("SetYear", 2015);
...

works fine for sx170, but it cause for some wrong settings for sx160. sx160 hangs after shoot also.
Try using the routines directly (by address), not through the eventproc interface.
InitializeAdjustmentFunction registers lots of event procedures and executes other routines. It's possible that some of those have a bad influence on normal camera operation. Or it just eats up a lot of memory and that results in a crash later. A romlog would maybe help figuring out the reason.

*

Offline reyalp

  • ******
  • 14080
Re: How to set date&time from fw?
« Reply #9 on: 19 / November / 2015, 00:31:40 »
_ExecuteEventProcedure("InitializeAdjustmentFunction");

_ExecuteEventProcedure("SetYear", 2015);
...

works fine for sx170, but it cause for some wrong settings for sx160. sx160 hangs after shoot also. What kind of differences between these cameras in InitializeAdjustmentFunction proc event?
I was able to reproduce this on my sx160. The following chdkptp commands crashed on shoot
Code: [Select]
con 5> =return call_event_proc'FA.Create'
con 1> =return call_event_proc'InitializeAdjustmentFunction'
con 2> =return call_event_proc('SetYear',2015),call_event_proc('SetMonth',11),call_event_proc('SetDay',18)
con 3> rec
con 4> shoot
The crash is
Code: [Select]
ASSERT!! BrtMthd.c Line 3119
It doesn't look like the registrations functions are taking up too much memory, the system heap has ~430k after running them.

I haven't tested whether all the eventproc calls are required to trigger the crash.
Don't forget what the H stands for.

 

Related Topics