chdkptp - alternative ptp client - page 62 - General Discussion and Assistance - CHDK Forum

chdkptp - alternative ptp client

  • 1106 Replies
  • 559862 Views
Re: alternative ptp client
« Reply #610 on: 26 / March / 2014, 06:22:52 »
Advertisements
Hello reyalp,
After days of working with chdk and chdkptp, between my A2500 and my raspberry pi, I am stuck :)
The idea of my project is to have 2 or more cameras of same model connected to a RPi and synchronised using multicam.lua. I run the commands I need from chdkptp using -r option and a txt file.
All is well so far. At the end, I would like to retrieve the last image from each camera. Getting the last image name, and downloading that image, is something I manage too. But I need to somehow script a loop through all possible devices and download the images.
So my question is: how do I select and connect to a camera using a script ? I have read all the docs I guess, and you write on your assembla page

Quote
The chdkptp CLI only supports one active connection at a time, but using the local Lua (! command) you can manipulate the con variable to switch between multiple connections.

How would one do that ? can you help ?
Thanks in advance.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #611 on: 27 / March / 2014, 00:52:52 »
Quote
The chdkptp CLI only supports one active connection at a time, but using the local Lua (! command) you can manipulate the con variable to switch between multiple connections.

How would one do that ? can you help ?
Thanks in advance.
Two cameras
Code: [Select]
$ chdkptp -i
___> list
-1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=...
-2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
Make connections:
Code: [Select]
___> !con1=chdku.connection{dev='\\\\.\\libusb0-0001--0x04a9-0x31bc',bus='bus-0'} return con1:connect()
=true
___> !con2=chdku.connection{dev='\\\\.\\libusb0-0002--0x04a9-0x311b',bus='bus-0'} return con2:connect()
=true
The 'return' tells you if the connection succeeded. The extra \\ are for windows device names, on linux you won't need them.

Code: [Select]
___> list
+1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=...
+2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
The '+' shows that the connections are connected, but not currently associated with the cli con variable.
Now to switch between them, you just do something like
Code: [Select]
___> !con=con1
con> list
*1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=...
+2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
The * shows that camera 1 is now connected to the cli, so a download command will download from that camera.

You could also write the whole download process in lua, something like
Code: [Select]
___> !for i,dev in ipairs(chdk.list_usb_devices()) do local lcon=chdku.connection(dev) lcon:connect() lcon:download('A/DISKBOOT.BIN',i..'_DISKBOOT.BIN') lcon:disconnect() end
obviously substitute your own filename for diskboot.bin, and possibly add some error checking.
Don't forget what the H stands for.

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #612 on: 28 / March / 2014, 18:37:37 »
Quote
The chdkptp CLI only supports one active connection at a time ...
A simple workaround is to make a copy of the chdkptp folder and use the two chdkptp in parallel for one camera each in separate terminal windows.
« Last Edit: 28 / March / 2014, 18:39:57 by tpont »

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #613 on: 28 / March / 2014, 21:33:56 »
A simple workaround is to make a copy of the chdkptp folder and use the two chdkptp in parallel for one camera each in separate terminal windows.
FWIW you don't need to copy the folder to run two instances.

Running multiple instances of chdkptp is a valid approach (edit: though not if you want synchronized shooting with multicam.lua as jhfelectric described), but you do have to be careful because the list and connect commands can cause the other instances connection to be reset. See this post and following http://chdk.setepontos.com/index.php?topic=6231.msg96441#msg96441
« Last Edit: 28 / March / 2014, 21:36:53 by reyalp »
Don't forget what the H stands for.

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #614 on: 29 / March / 2014, 11:40:45 »
FWIW you don't need to copy the folder to run two instances.
Ok, will test that. Might save 3MB of disk space. :P

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #615 on: 01 / April / 2014, 01:57:13 »
I've uploaded snapshot build r511 to the files area.

The linux builds now include "readline" support for editing and history in the cli. If you are building yourself, you will need to update your config.mk to enabled this. See config-sample-linux.mk for examples.

There are also some improvements to remoteshoot: You can use rsint from the GUI (using CLI commands, an actual GUI for this feature would be nice), and if you are using chdk 1.3, failed connections are handled better in rs and rsint.

All the GUI builds now use CD 5.7 and IUP 3.10.1. Building with older libs should still work.

Raspberry pi users who want the GUI will need to update the library package to chdkptp-raspbian-libs-20140331.zip from the files area. This library package now includes everything you need to build chdkptp with the gui. I have also improved the documentation README-RASPI-LIBS.TXT.

chdkptp now supports Lua 5.2. This is currently experimental and optional, but will likely be mandatory in the future since it will allow significant improvement in the GUI.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #616 on: 02 / April / 2014, 01:32:41 »
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:

Code: [Select]

        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.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #617 on: 02 / April / 2014, 16:02:19 »
The above will retrieve the last image from all available cameras.
Glad you got it working.

note there is some possibility that things will break if the camera increments the folder number, I'm not certain whether the image dir will refer to the current or previous folder. This is somewhat annoying to test for obviously reasons...
Quote
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.
This sounds like a bug in the port, elph130 had a similar issue which I worked around with this hack:
http://trac.assembla.com/chdk/browser/trunk/platform/ixus140_elph130/shooting.c#L143
If you have the ability to build your own CHDK, you can try this same thing. If not, I can make a test build for you.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #618 on: 06 / April / 2014, 02:17:27 »
In r516 (svn, no official build yet), I moved rsint into the standard cli, so the require'extras/rsint'.init() is no longer required and will result in an error.

edit:
r521 adds camera selection to the GUI. The dropdown to the left of the "connect" button keeps a list of available cameras. You can have multiple cameras connected and use the dropdown to switch between which one you are controlling.

This is preliminary, there are some known issues and probably some unknown ones too.
The list is just bus:device rather than camera names
The files tab collapses any time you switch cameras, to avoid showing the wrong file list. Really, the tree should have a branch for each camera.
« Last Edit: 06 / April / 2014, 18:08:23 by reyalp »
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: alternative ptp client
« Reply #619 on: 08 / April / 2014, 18:42:17 »
The new readline support is really useful, one doesn't have to mess with the clipboard any more. I'm wondering if it would be somehow possible to not request liveview data until the previous frame has arrived? The linux GUI still jams when the requested framerate is larger than what's physically possible.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal