while #chdk.list_usb_devices() == 0 do
sys.sleep(100)
end
-- camera has appeared, connect to it
cli:execute('connect')
-- tell the camera script the download is done and it can reset the remote bit and resume shooting
Every tenth of a second is better than per second so that's a keeper
Download done is a bit more tricky i guess and led me to create the -not working- 10 sec window:
if we download a file after shot taken and reset the remote bit after download. it will probably not interfere with even the shortest interval. However, pc has to be active 24/7 with no flaws.
if we download in bulk and wait to finish, this will stop the interval timer for quite some time. ~12Gb a day for the S110 at USB2 speed....max 30Mb/s.....7 minutes plus erase and reboot: minimum 16 frames lost.
Scale that to what would happen if we could remove the limit and i could do a weekly or longer download before erasing and rebooting...i would loose close to an hour per download.
As far as i can see bulk would thus entail downloading in groups of a fixed number or as much as possible images between each shot.
f. i. If we could do groups of only 3 it would download 24 hours of pictures in 8 hours. the pc could possibly be scripted to power down after that.
A script running does not prevent the OS or chdkptp from seeing the camera. If you connect in the GUI while a script is running, you'll see an error like 'update_mode_list failed a script is already running' but this does not prevent connecting or using other functions which do not use camera script.
From CHDKs POV, script is "running" regardless of whether it's in sleep or actually doing something.
Thanks, i think i understand the working of chdkptp and the buttons in the gui much better by now.
i assume we can not download while a shot is being taken and written to the sd card.
Haven't been able to replicate the error you wrote while the cam had switched to play and script was sleeping.
That may have been poor timing on my side though.
I've only seen 'a script is already running' when i tried the download button while cam was running script, with use of: set_config_value(121,1)
It looks like the SUIx log you posted contains both the folder and image name. So you should be able to do something like
download A/SUIx.csv
parse SUIx into a list of full paths
download the files
Of course, you could arrange your script to write just the file names to a different file, to make the parsing easier. It just has to be a predictable name the chdkptp side can download.
As long as the downloads use download -nolua or the equivalent chdkptp Lua, your camera side script doesn't need to exit.
I can provide more specific code suggestions, but it will depend on what approach you want to try
i'm happy with the folder/img structure canon uses copied on the pc if they are dropped in a folder that spans all folders/images between reboot with the csv of that period.
When i started i used weeknumbers since i had 64Gb cards, now i use month names to keep the folders of different downloads seperated.
However, with the file limit it will be a daily download, that's why i wrote a download-dated folder.
Working with a 24/7 powered pc that would download every interval would be my second choice...and probably how i would set it up for testing.
It would be nice because you have the shots direcly available for processing, not after a day or more.
But if 24/7 is a necessity to make it work it would probably lead to more downtime wouldn't you think?
I would favor some form of bulk copying giving the ability to power down and up the pc (or unplug usb), to me that sounds like the most stable solution.
This would lead to a bit more steps than you suggested, maybe something in the line of:
#!/bin/bash
# Purpose: Copy files to pc without interrupting interval on cam
# ------------------------------------------
logname=SUIx.csv
cam_id_p=0x325b
-- wait until connection is available
while #chdk.list_usb_devices() == 0 do
sys.sleep(100)
end
-- camera has appeared, connect to it
cli:execute('connect')
-- get the list of files to download or use the last folder name/image number downloaded for your next batch.
-- download the next batch of images or download images for X seconds to the same name folder/file on the pc.
-- tell the camera script the download is done and it can reset the remote bit and resume to next shot, after it sets remote bit again.
-- repeat download batch sequence after reconnect until no new images available/found
-- reboot time <= current time
-- download final csv for this series
-- erase folder DCIM and SUIx.csv from cam: rm A:\DCIM A:\SUIx.csv
-- set_clock to current time
-- reboot cam
-- set next reboot moment (file limit and interval dependant, for now that's one day)
-- create new download-dated folder: mkdir -p "%Y/%m%d"
-- repeat the script.
This way the erase will only be triggered once per run, and the on-camera reboot sequence i use already moves the camera to play before reboot to prevent crashing that feature on some models.
I think the same reboot sequence and minimum timing should be used in this setup, since it took a lot of testing and refining to get it to work stable on most cams.
If we were the erase to be triggered there, just before or after set_clock it should prevent cams that can't handle erase in record to crash.
-- routine to reboot the camera and restart the cam script
function camera_reboot()
activate_display(20)
switch_mode(PLAYBACK)
local ts=11 -- allow 11 seconds in case camera not setup to retract immediately
if (debug_mode ) then ts=10 end
printf(" Scheduled reboot ")
printf(" lens retraction wait")
repeat
show_msg_box(string.format(" rebooting in %d", ts))
ts=ts-1
sleep(1000)
until ( ts == 0)
f:flush()
f:close()
end
-- time to restart ?
if (elapsed_days ~= maximum_days) then
set_autostart(2) -- autostart once
printf(" rebooting now\n\n")
sleep(1000)
t=os.date('*t', os.time()) --change to pc os time
set_clock(t.year,t.month,t.day,t.hour, t.min, t.sec) -- set_clock(year, month, day, hour, minute, second)
printf(" time set %d sec\n\n", reboot_tcorr)
-- rm A:\DCIM A:\SUIx.csv – remove old files and folders
sleep(1000)
reboot()
end
end
The reason to trigger a reboot from the script after the erase is to make sure it reboots when no images/folders/log are on the card creating a fresh SUIx.csv and 100* folder with img_0001.jpg to start with for the next sequence.
It would help to keep things organised.
Since we started somewhere in this thread with that need, i adapted the SUIx log to contain folder names. But later thought that we might not need it since the folder and files are numbered predictable.
If you have time for some more specific code suggestions i would really appreciate that
Making less progress by turning down the offer for help and guide from a specialist? I'm not that hard on myself nor experienced enough to decline