get_tick_count overflow after 24 days - Script Writing - CHDK Forum

get_tick_count overflow after 24 days

  • 60 Replies
  • 20223 Views
get_tick_count overflow after 24 days
« on: 02 / March / 2019, 14:32:02 »
Advertisements
What will CHDK LUA get_tick_count() return after 24+ days?

My thoughts:
Return value should be 32 signed integer
Most probably answer is just 2147483647 + 1 -> -2147483648
But it could also cap at last integer second and wrap to 0 or some other stuff

Just want to confirm this...  without running camera for few weeks :)

*

Offline reyalp

  • ******
  • 14126
Re: get_tick_count overflow after 24 days
« Reply #1 on: 02 / March / 2019, 15:51:45 »
What will CHDK LUA get_tick_count() return after 24+ days?

My thoughts:
Return value should be 32 signed integer
Most probably answer is just 2147483647 + 1 -> -2147483648
But it could also cap at last integer second and wrap to 0 or some other stuff

Just want to confirm this...  without running camera for few weeks :)
FWIW, I wouldn't assume that the Canon firmware handles this situation correctly, so my recommendation would be to reboot before that. Even if it appears to work, there could be subtle impacts.

I think some people may have run cameras this long, but I don't recall any detailed reports of exactly what happened. Assuming the camera keeps incrementing (which would be my guess), the tick count in lua would indeed go negative.
Don't forget what the H stands for.

*

Offline c_joerg

  • *****
  • 1251
Re: get_tick_count overflow after 24 days
« Reply #2 on: 02 / March / 2019, 16:54:25 »
If you had asked the question a month ago, then I could give you an answer. I stopped my camera after 23 days. get_tick_count () can be found in the third column (tick) in the logfile.
May be next time  ;)
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline reyalp

  • ******
  • 14126
Re: get_tick_count overflow after 24 days
« Reply #3 on: 02 / March / 2019, 18:24:05 »
If you had asked the question a month ago, then I could give you an answer. I stopped my camera after 23 days. get_tick_count () can be found in the third column (tick) in the logfile.
May be next time  ;)
Yes, if you do another one of these it would definitely be good to know what happens.

One other thing to watch out for is that calculations can overflow before the actual wraparound time, like
Code: [Select]
time_for_next_shot=get_tick_count() + some_value
wait until get_tick_count() >= time_for_next_shot
time_for_next_shot becomes negative immediately, less than the still positive get_tick_count.

The firmware likely does some calculations of this sort, though I'd expect most are on the order of seconds rather than days.
Don't forget what the H stands for.

Re: get_tick_count overflow after 24 days
« Reply #4 on: 02 / March / 2019, 23:52:55 »
Just want to confirm this...  without running camera for few weeks :)
Or yo=u could do like this script :  Ultimate Intervalometer and automatically reboot the camera every couple of days.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline c_joerg

  • *****
  • 1251
Re: get_tick_count overflow after 24 days
« Reply #5 on: 03 / March / 2019, 01:36:27 »
One other thing to watch out for is that calculations can overflow before the actual wraparound time, like
Code: [Select]
time_for_next_shot=get_tick_count() + some_value
wait until get_tick_count() >= time_for_next_shot
time_for_next_shot becomes negative immediately, less than the still positive get_tick_count.
I could do the same think with os.time…
Where is the advantage of this method over os.time?
https://chdk.setepontos.com/index.php?topic=13675.0

M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline reyalp

  • ******
  • 14126
Re: get_tick_count overflow after 24 days
« Reply #6 on: 03 / March / 2019, 16:37:46 »
One other thing to watch out for is that calculations can overflow before the actual wraparound time, like
Code: [Select]
time_for_next_shot=get_tick_count() + some_value
wait until get_tick_count() >= time_for_next_shot
time_for_next_shot becomes negative immediately, less than the still positive get_tick_count.
I could do the same think with os.time…
Where is the advantage of this method over os.time?
https://chdk.setepontos.com/index.php?topic=13675.0
os.time only has second resolution, which may or may not matter to you, but my example was just meant to show a kind of calculation that would have problems before the actual wraparound.

Script logic could be adjusted to deal with all this, but the risk is that the Canon firmware (or CHDK C code) does calculations with tick values internally that could start to have problems. So for people who are really worried about long runs, I'd recommend ensuring the camera is rebooted some time (maybe a day or so) before the overflow unless they've actually verified with testing.

edit:
In fact, the action_stack code used for blocking script functions in CHDK does something very much like this, but uses unsigned values so might work up to ~49 days instead of ~24.
« Last Edit: 03 / March / 2019, 19:16:27 by reyalp »
Don't forget what the H stands for.

Re: get_tick_count overflow after 24 days
« Reply #7 on: 04 / March / 2019, 11:02:31 »
Just want to confirm this...  without running camera for few weeks :)
Or yo=u could do like this script :  Ultimate Intervalometer and automatically reboot the camera every couple of days.

This is probably safest approach, to avoid any non-script bugs as well. Also thanks for noting about ultimate.lua, this has most and more features that I implemented on my own in past couple of years, will take a look!

*

Offline c_joerg

  • *****
  • 1251
Re: get_tick_count overflow after 24 days
« Reply #8 on: 18 / April / 2019, 01:54:18 »
What will CHDK LUA get_tick_count() return after 24+ days?

Negative values ;)

Yes, if you do another one of these it would definitely be good to know what happens.
 

My camera has been running for over 24 days now. The tick counter became negative (line 7174 in the log file). Otherwise, the script continued and took pictures.

@srsa_4c
I notice one problem. Cancel of retract timer does not work anymore. This can be seen in the focal length in the penultimate column which goes from around 50mm to 24mm.

M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline srsa_4c

  • ******
  • 4451
Re: get_tick_count overflow after 24 days
« Reply #9 on: 18 / April / 2019, 15:46:21 »
I notice one problem. Cancel of retract timer does not work anymore. This can be seen in the focal length in the penultimate column which goes from around 50mm to 24mm.
Are you sure that all parts of the script can cope with negative tick count?

edit:
If it's not the script, then the firmware's UI timer routines are failing. This would probably have other signs on the camera UI (could affect drawings that blink or move).
« Last Edit: 18 / April / 2019, 16:17:21 by srsa_4c »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal