Reyalp and others, about the multiple connections,
Thanks a lot for your reply, I managed to make it work easily with your input.
Here is (part of) the code I can run successfully:
devices, devices_error = chdk.list_usb_devices()
for device, devinfo in ipairs(devices) do
printf('camera %i:', device)
a_connection, a_connection_message = chdku.connection(devinfo)
connection_status, connection_error = a_connection:connect()
exp_count_status, last_number = a_connection:execwait([[return get_exp_count()]])
printf(' last image number is %i...', last_number)
if exp_count_status then
image_dir_status, image_dir = a_connection:execwait([[return get_image_dir()]])
if image_dir_status then
temp_file = string.format('%s/IMG_%04d.JPG', image_dir, last_number)
image_file = string.gsub(temp_file, string.format('/ETC_%04d.TMP', last_number), '')
printf('downloading %s...', image_file)
download_status = a_connection:download(image_file, 'IMAGE'..device..'.JPG')
end
end
disconnection_status = a_connection:disconnect()
printf('done\n')
end
The above will retrieve the last image from all available cameras.
You have noted that the "get_image_dir", which is supposed to return the current image directory, actually returns a temporary folder name, based on the last image's number. I could not figure out how or why, so I needed to skip out that part. Fyi, all my cameras are A2500.