Yes, i set the script to disable usb remote after each shot assuming that i could only download when the camera is in play mode.
If that is a wrong assumption, correct me, because i could do without all that switching between play and shoot.
With chdkptp, you do not have to be in play mode to download files. However, depending on how you do things, you might still want or need to switch to play or use the USB remote setting like you described above.
1) If the Canon firmware detects a new USB connection (+5v goes from 0 to +5) it switches to play mode. Having this happen at a random point while your script was shooting would likely be bad. Additionally, after the camera has done this automatic switch, switching under CHDK control is likely to be broken until you reboot or maybe disconnect USB.
So
if your USB connection is only powered intermittently when you want to download files, then you probably want to use the USB remote setting to block the Canon firmware from detecting it, and use script to switch to playback before allowing the Canon firmware to notice the USB connection.
If the USB connection is powered all the time then hiding the USB connection should not be necessary. You can either download in rec, or use CHDK script functions to switch between play and rec.
2) On
some cameras, if you delete image files while in rec, the camera crashes when you attempt to switch to playback or shut down. Since you need to limit the number of files to avoid the "COMMUNICATION ERROR" issue we discussed earlier, you may need to switch to playback to delete. However, this does not require that you use the USB remote setting, you can just switch between play and rec using CHDK script functions if USB is always present.
And yes, it was hard to time, since that 10 seconds only are 6 or 7 after the cam is connected. But as i understand now it would never work because the script is paused and the download button in the gui request a file lookup on the cam.
For actual use, you will surely want to use some chdkptp side script, not the GUI button. Conceptually, if you wanted the PC side to wait for the camera to enable the USB connection and then download, you could do something like this in chdkptp Lua
-- wait for a device to appear
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
-- download the files
-- tell the camera script the download is done and it can reset the remote bit and resume shooting
Note I'd generally use the chdkptp CLI rather than the GUI for this kind of automation. chdkptp automatically starts in CLI mode if given command line arguments other than -g.
However, if you want to download frequently (every shot or few shots), then IMO it would make more sense to just have USB connected all the time. In that case, your camera side script could send the filename(s) in message with write_usb_msg and your chdkptp side script could use con:wait_msg or con:wait_status
it does not see any compatible device because the script is still running on the camera,
it has only disabled usb remote and is now sleep(10000) until it will enable usb remote and go back to 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.
-i know the file names for each folder: starting with: IMG_0001.JPG until: IMG_XXXX.JPG (this can be anywhere from 2 to 2000, if there is no reboot or other disruption:2 folders per day one of 2000 the other 880),
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.