while #chdk.list_usb_devices() == 0 do sys.sleep(100)end-- camera has appeared, connect to itcli:execute('connect')-- tell the camera script the download is done and it can reset the remote bit and resume shooting
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.
It looks like the SUIx log you posted contains both the folder and image name. So you should be able to do something likedownload A/SUIx.csvparse SUIx into a list of full pathsdownload the filesOf 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
#!/bin/bash# Purpose: Copy files to pc without interrupting interval on cam# ------------------------------------------logname=SUIx.csvcam_id_p=0x325b-- wait until connection is availablewhile #chdk.list_usb_devices() == 0 do sys.sleep(100)end-- camera has appeared, connect to itcli: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.
-- routine to reboot the camera and restart the cam scriptfunction 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() endend
sudo sh /chdkptp-r964/chdkptp.sh -c"-p=0x325b" -e"set_lcd_display(1)" -e"switch_mode(PLAYBACK)" -e"exec sys.sleep(11000)" -e"set_autostart(2)" -e"rm A:/DCIM A:/SUIx.csv" -e"exec sys.sleep(1000)" -e"set_clock(%Y,%m,%d,%H,%M,%S)" -e"exec sys.sleep(1000)" -e"reboot()"
Code: [Select]sudo sh /chdkptp-r964/chdkptp.sh -c"-p=0x325b" -e"set_lcd_display(1)" -e"switch_mode(PLAYBACK)" -e"exec sys.sleep(11000)" -e"set_autostart(2)" -e"rm A:/DCIM A:/SUIx.csv" -e"exec sys.sleep(1000)" -e"set_clock(%Y,%m,%d,%H,%M,%S)" -e"exec sys.sleep(1000)" -e"reboot()"
-e"luar set_lcd_display(0)"
switch_mode(PLAYBACK)
-e"set_clock(%Y,%m,%d,%H,%M,%S)"
-e"clock -sync"
-e"reboot()"
chdkptp.sh -e"source somefile.chdkptp"
chdkptp.sh -e"exec dofile('somefile.lua')"
Download done is a bit more tricky i guess and led me to create the -not working- 10 sec window:
read_usb_msg(10000)
putm done
local m=read_usb_msg(10000)if m == nil then... handle timeoutelseif msg == 'done' then... do something elseelseif msg == ...
write_usb_msg(string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count()))
exec local m=con:wait_msg{mtype='user'} some_download_function(m.value)
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.
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.
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)
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.
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.
But if 24/7 is a necessity to make it work it would probably lead to more downtime wouldn't you think?
Possible, but it depends where the unreliability is. With stable power or sufficient backup, a Linux PC may not be the weakest link. It also depends on the failure modes, if the USB connection goes away, does the camera just keep shooting and saving to the card until you fix it, or do you lose a bunch of shots.
-- reboot.chdkptpluar set_lcd_display(1)luar set_record(0)exec sys.sleep(11000)luar set_autostart(2)rm A:/DCIM A:/SUIx.csvexec sys.sleep(1000)clock -syncexec sys.sleep(1000)reboot
at this moment i can connect and disconnect without loosing shots, but only with the gui and live view.i can't even manage a connect in the terminal version.
and yes, you are right the posts are getting too long, i'll do my best to keep it shorter.
if I understand your suggestion of a seperate file and calls, it would lead to something like this:
the same with the gui, i can connect before i start SUIx and get live view, as soon as SUIx is running i cannot change anything anymore, but live view stayes active. if i disconnect the cam goes on.
the cam now stops completely and after a minute it goes to play. disabling the script is not possible, but won't take shots since in play.
I tested the following, on both windows and raspberry pi, using elph180* power on camera, remote not enabled, switch type = none, control mode = none* connect USB cable
* chdkptp list command shows the camera, connect / disconnect works* with chdkptp disconnected, enable remote in CHDK menu
* chdkptp list does not show the camera, nothing to connect to* disable remote in CHDK menu
* chdkptp list command shows the camera, connect / disconnect work
cam turns to play
Started by jjudd General Help and Assistance on using CHDK stable releases
Started by flarg General Discussion and Assistance
Started by CanonBlue General Help and Assistance on using CHDK stable releases
Started by d10 General Discussion and Assistance
Started by danx88 Script Writing