CHDK for longtime timelapse - page 10 - General Help and Assistance on using CHDK stable releases - CHDK Forum

CHDK for longtime timelapse

  • 133 Replies
  • 29793 Views
Re: CHDK for longtime timelapse
« Reply #90 on: 08 / November / 2021, 16:10:58 »
Advertisements
If you can see when the LED stops blinking that would give you an idea how long it takes. The canon UI also doesn't show the total number of images until it's done.
Code: [Select]
    repeat sleep(1000) until get_jpg_count() --(??)--(??)--
 

Thanks!
This seems interesting and maybe the better way of coding it.
So while get_jpg_count() returns 0 the camera is still indexing and not responding to button clicks?

how would bee the code snipplet if I want to execute it in chdkptp?
Code: [Select]
luar repeat sleep(1000) until get_jpg_count()

but how would the code look like if I want some feedback, of how many loops it has done?

pseudo code:
Code: [Select]
!print(con:execwait[[repeat [b]print[/b] "waiting 1 sec until get_jpg_count gives count greater than 0 back" sleep(1000) until get_jpg_count() ]])
I'm not sure about the second print command. I know return would work, but only once.  ???

I haven't actually found anything about indexing when switching from Rec to Play, except in this forum which I' ve already read for the topic of a reboot every 24 days: https://chdk.setepontos.com/index.php?topic=13714.20
If you want to see a sunset or sunrise of Dolomiti Val Gardena shot with CHDK visit
Instagram: dolomiti_timelapse
YouTube: https://www.youtube.com/channel/UCEJHg--ujxLkjMrevJXh-Gw

*

Offline reyalp

  • ******
  • 14128
Re: CHDK for longtime timelapse
« Reply #91 on: 08 / November / 2021, 16:22:29 »
So while get_jpg_count() returns 0 the camera is still indexing and not responding to button clicks?
As I stated in my reply, I do not believe it works this way.
Quote
Code: [Select]
luar repeat sleep(1000) until get_jpg_count()
Remember, in Lua, everything other than nil or false is true, so you'd want until get_jpg_count() ~= 0. But again, I'm pretty sure get_jpg_count() isn't going to do what you want.
Don't forget what the H stands for.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: CHDK for longtime timelapse
« Reply #92 on: 09 / November / 2021, 11:12:20 »
Have you tested this?
Exceptionally not.  :(  I hoped for a return value of the booting process or one that´s initialized after that. Now I tried with autostart
Code: [Select]
print_screen(-8769)
while 1 do
print(get_tick_count())
print(get_exp_count(), get_jpg_count(), get_raw_count(),-get_free_disk_space())
    sleep(100)
end
... but the lines are constant, like 359 0 15 -400736 on a 512Mb card, sorry...

The erase all images in one line works fine for the DCIM folder.  :)

Edit: Now I just added set_record(1) as the 1st. line and got
Quote
1440
359 0 11 -307808
1930
359 0 11 -307792
2240
359 12 5 -307792
...
so something seems usable ...  ???
« Last Edit: 09 / November / 2021, 11:37:52 by Caefix »
All lifetime is a loan from eternity.

Re: CHDK for longtime timelapse
« Reply #93 on: 10 / November / 2021, 05:31:54 »
Code: [Select]
while 1 do
print(get_tick_count())
print(get_exp_count(), get_jpg_count(), get_raw_count(),-get_free_disk_space())
    sleep(100)
end
so something seems usable ...  ???

I tested this code for a test time lapse:
Code: [Select]
exec sys.sleep(10000) # waiting until indexing is finished

!freeDiskSpaceBefore = con:execwait[[ return get_free_disk_space()]]
exec sys.sleep(100)
!print'avoid lense retraction after 1 minute'
exec con:call_function(0xff099f1c)
exec sys.sleep(1000)

!print'delete dummy files on sd card'
luar function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end c("menu") c("down",4) c() c("up") c() c("right") c() sleep(10000)

!freeDiskSpaceAfter = con:execwait[[ return get_free_disk_space()]]

!if freeDiskSpaceBefore < freeDiskSpaceAfter then printf('photos deleted\n') else printf('ERROR: photos have not been deleted') end

I don't understand the part: function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end

what is c(k,x)? is c the name of the function? and k,x the parameters?
Whould this be the logic:
function c(k,x)
  for x=1,x or 1 do #if x==NULL than use 1
    click(k or "set") #if k==NULL than use "set"?
    sleep(500)
  end
end

The problem with the code snippet above is that the difference between bevore and after running the deleted function is only "64"(kB?) because of the 0kB of the Dummies. This may be unsecure. A better approach would be the count of the files in DCIM but after a short reseach I could not find any function.

the next step would be a small do while loop

Code: [Select]
!freeDiskSpaceBefore = con:execwait[[ return get_free_disk_space()]]
exec sys.sleep(100)
!iteration = 0
!repeat con:execwait[[function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end c("menu") c("down",4) c() c("up") c() c("right") c() sleep(10000)]] iteration = iteration + 1 printf('photos deleted, attempt no %d\n', iteration) until(freeDiskSpaceBefore < con:execwait[[ return get_free_disk_space()]] or iteration > 2 )
exec sys.sleep(100)

This code worked in a first attempt.
Iteration is only for limiting the repeat until loop iteration to a small number if the comparison of disksize should not work.

I think it should be more robust running the code camera internally (like shown in the last code block) for deleting all photos than using single command lines via chdk ptp.
« Last Edit: 10 / November / 2021, 12:30:22 by dolomiti_timelapse »
If you want to see a sunset or sunrise of Dolomiti Val Gardena shot with CHDK visit
Instagram: dolomiti_timelapse
YouTube: https://www.youtube.com/channel/UCEJHg--ujxLkjMrevJXh-Gw

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: CHDK for longtime timelapse
« Reply #94 on: 10 / November / 2021, 12:03:13 »
Several ... :)  :D ...
*> luar file_browser(get_image_dir())
*Gives a nice feedback, escape with mouse~~>PressPrintShareButton*   8)(exit_alt(1))

if get_jpg_count()==0 then print("Cam has not been in rec_mode(1), entering menu could fail") end

--[[ pantomiming universally most everage buttonclicker... ]]--
https://chdk.setepontos.com/index.php?topic=14302.msg147262#msg147262

if get_image_dir()=="A/DCIM"  then print("No Image.") end


o: There´s a well hidden way to crash  file_browser manually...

Edit: *file_browser only usable if <exit_alt>  :-X is available on local keypad*
else: ERROR: a script is already running loop...
« Last Edit: 10 / November / 2021, 14:23:56 by Caefix »
All lifetime is a loan from eternity.

Re: CHDK for longtime timelapse
« Reply #95 on: 10 / November / 2021, 12:13:30 »
I found a lot of .ctg files on the SD card. And I read up on the internet what these are needed for....

It says that .ctg files are used for indexing and all .ctg files are deleted if there are no pictures on the SD card. Could the .ctg files cause problems if they are missing or if there are many of them? I couldn't find a topic about .ctg on chdk, which I can't believe :blink:

I have now deleted old .ctg files and kept only the newest one.(last modified about a month ago)

I now deleted the DCIM directory and shoot 2 pictures on the sd card and the DCIM structure with a new ctg file returned. after I deleted all images via the canon menu the photos and .ctg file have been both delted.


« Last Edit: 10 / November / 2021, 12:22:17 by dolomiti_timelapse »
If you want to see a sunset or sunrise of Dolomiti Val Gardena shot with CHDK visit
Instagram: dolomiti_timelapse
YouTube: https://www.youtube.com/channel/UCEJHg--ujxLkjMrevJXh-Gw

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: CHDK for longtime timelapse
« Reply #96 on: 10 / November / 2021, 13:04:55 »
I couldn't find a topic about .ctg on chdk, which I can't believe :blink:
Seems a good sign...  :haha
« Last Edit: 10 / November / 2021, 15:56:10 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14128
Re: CHDK for longtime timelapse
« Reply #97 on: 10 / November / 2021, 16:21:34 »
A better approach would be the count of the files in DCIM but after a short reseach I could not find any function.
See os.idir in https://chdk.fandom.com/wiki/Lua#Added_features_2 if you want to iterate over files in a directory. Note that because the amount of memory available to CHDK is very limited, the simple approach of listing all files (either with os.listdir or building a list from idir results) and then doing something with them should be avoided for image directories that potentially have thousands of files. Instead you want to do something like
Code: [Select]
for fname in os.idir("path") do
  do_something_with_fname)

If you want to do it from chdkptp, you can use 'find_files' or 'ff_imglist' in rlibs.lua https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/lua/rlibs.lua which handle batching the file information in reasonable sized chunks.

That said, I don't really understand understand what the proposed code is supposed to do.

I found a lot of .ctg files on the SD card. And I read up on the internet what these are needed for....

It says that .ctg files are used for indexing and all .ctg files are deleted if there are no pictures on the SD card. Could the .ctg files cause problems if they are missing or if there are many of them? I couldn't find a topic about .ctg on chdk, which I can't believe :blink:
Yes, I'm not aware of any work on this forum directly reverse engineering the ctg files. It's related to the metactg task discussed in https://chdk.setepontos.com/index.php?topic=11481.0 and https://chdk.setepontos.com/index.php?topic=13714.msg140111#msg140111

If your search turned up any reverse engineering information on these files, linking it here would be very welcome.

There seems to be 1 CTG file for each DCIM subdirectory, with the files size depending on the number of images. They do seem to get left lying around sometimes, with no obvious ill effect. I've also deleted them, with no obvious effect beyond causing the camera to re-do the "indexing" (non-obvious ill effects may be present, of course ;))
Don't forget what the H stands for.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: CHDK for longtime timelapse
« Reply #98 on: 12 / November / 2021, 12:20:55 »
Took a look ... :( can only tell, that the char right of highlight is Ascii+0x4 per line.
The next one belongs to the same (little endian) counter.

Edit:  :-[ Speculating...
File seems to be a "headline" followed by "one line" per image. Line could look broken by linefeed chars.
Length seems to differ.
M238.ctg probably read only when according folder A/DCIM/238__11 found.
Deleting a image (with explorer) takes out a line and changes "the" char the line before to Ascii+0x8.
LF could be a .jpg marker, video lines are quite long.
No line for unnkown sized images like screenshot-cuts?

Just swapping cam around sd-card forces long boot, without changing .ctg?
(& What´s Cam-dependent?)

Now I took an empty card, booted to record, took some pics, looked  :-[ ... no  canonmsc nor .ctg written;
then booted to review, looked again, both arrived ...
« Last Edit: 13 / November / 2021, 11:08:34 by Caefix »
All lifetime is a loan from eternity.

Re: CHDK for longtime timelapse
« Reply #99 on: 29 / November / 2021, 05:17:58 »
This is a short feedback on my last long term test:  :)

Which started on Nov 10 with this code change (if you are interested in the full chdkptp code, see the zip file for the chdkptp files) to delete all dummy files after a timelapse capture with remoteshoot using dummy files:
Code: [Select]
!freeDiskSpaceBefore = con:execwait[[ return get_free_disk_space()]]
exec sys.sleep(100)
!iteration = 0
! repeat con:execwait[[function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end c("menu") c("down",4) c() c("up") c() c("right") c() sleep(10000)]] iteration = iteration + 1 printf('photos deleted, attempt no %d\n', iteration) until(freeDiskSpaceBefore < con: execwait[[ return get_free_disk_space()]] or iteration > 2 )
exec sys.sleep(100)

From what I could tell, the code worked 100% of the time, which is very pleasing. The dummy files are now completely deleted after each time-lapse.

Also, I have not missed a single time-lapse because of a camera crash. This is not because there was no crash, but because the powershell code is able to detect a crash and manually restart the camera with the servo linked to the on-off button.

The camera crashed on 11/14/2021, 11/16/2021, 11/21/2021, I will attach the log file and crash report and chhdkptp file for these 3 crashes, but from previous experience I have little hope that we will get any new valuable information as to why they happened.
 ???
« Last Edit: 29 / November / 2021, 05:20:37 by dolomiti_timelapse »
If you want to see a sunset or sunrise of Dolomiti Val Gardena shot with CHDK visit
Instagram: dolomiti_timelapse
YouTube: https://www.youtube.com/channel/UCEJHg--ujxLkjMrevJXh-Gw

 

Related Topics


SimplePortal © 2008-2014, SimplePortal