CHDK PTP multiple instances - General Discussion and Assistance - CHDK Forum

CHDK PTP multiple instances

  • 180 Replies
  • 73498 Views
CHDK PTP multiple instances
« on: 04 / October / 2012, 10:21:20 »
Advertisements
I'm trying to run multiple instances of CHDKPTP in parallel to connect to multiple instances, but facing some problems. If I try to run them on the command line, the first one is ok:

Code: [Select]
$ chdkptp
___> list
-1:Canon PowerShot A810 b=002 d=006 v=0x4a9 p=0x323f s=DA4C8A51BA3B444B9A2C6C2345FE77CF
-2:Canon PowerShot A810 b=002 d=007 v=0x4a9 p=0x323f s=1862F4922B5343A2AB2067DA16AE8731
___> c -s=DA4C8A51BA3B444B9A2C6C2345FE77CF
connected: Canon PowerShot A810, max packet size 512
con> ls
CHDK/
DCIM/
DISKBOOT.BIN
changelog.txt
paramdmp.log
readme.txt
ver.req
vers.req

The second one , however, outputs an error, then works:

Code: [Select]
___> list
open_camera_dev: ptp_opensession failed 0x2ff
open_camera_dev:usb_ptp_device_reset(): Input/output error
usb_ptp_get_device_status(): Input/output error
-1:Canon PowerShot A810 b=002 d=006 v=0x4a9 p=0x323f s=DA4C8A51BA3B444B9A2C6C2345FE77CF
-2:Canon PowerShot A810 b=002 d=007 v=0x4a9 p=0x323f s=1862F4922B5343A2AB2067DA16AE8731
___> list
-1:Canon PowerShot A810 b=002 d=006 v=0x4a9 p=0x323f s=DA4C8A51BA3B444B9A2C6C2345FE77CF
-2:Canon PowerShot A810 b=002 d=007 v=0x4a9 p=0x323f s=1862F4922B5343A2AB2067DA16AE8731
___> c -s=1862F4922B5343A2AB2067DA16AE8731
connected: Canon PowerShot A810, max packet size 512
con> ls
CAM_0001.TXT
CHDK/
DCIM/
DISKBOOT.BIN
changelog.txt
readme.txt                                                                                                                                             
tmp/                                                                                                                                                   
ver.req                                                                                                                                               
vers.req                                                                                                                                               
con 1>

If I try to list the cameras in the first instance, the same error happens. The error happens only with "list" and only if I switch from one instance to another. But other than this, it works.

However, if I try to run them from an application in two threads, here's what I get:

Code: [Select]
Camera -1:Canon PowerShot A810 b=002 d=010 v=0x4a9 p=0x323f s=DA4C8A51BA3B444B9A2C6C2345FE77CF

Camera -2:Canon PowerShot A810 b=002 d=009 v=0x4a9 p=0x323f s=1862F4922B5343A2AB2067DA16AE8731

open_camera_dev:usb_ptp_device_reset(): Input/output error
usb_ptp_get_device_status(): Input/output error
open_camera_dev:usb_ptp_device_reset(): Input/output error
usb_ptp_get_device_status(): Input/output error
ERROR: /usr/share/chdkptp/lua/chdku.lua:103: attempt to index field 'ptpdev' (a nil value)
stack traceback:
        /usr/share/chdkptp/lua/chdku.lua:103: in function 'match_ptp_info'
        /usr/share/chdkptp/lua/cli.lua:1192: in function </usr/share/chdkptp/lua/cli.lua:1152>
        (tail call): ?
        (tail call): ?
        [C]: in function 'xpcall'
        /usr/share/chdkptp/lua/cli.lua:239: in function 'execute'
        /usr/share/chdkptp/lua/main.lua:188: in function 'do_execute_option'
        /usr/share/chdkptp/lua/main.lua:208: in function 'do_no_gui_startup'
        /usr/share/chdkptp/lua/main.lua:222: in main chunk
        [C]: in function 'require'
        [string "require('main')"]:1: in main chunk
ERROR: not connected
runningrunningchdkptp -e'connect -s=DA4C8A51BA3B444B9A2C6C2345FE77CF' -e'ls'chdkptp -e'connect -s=1862F4922B5343A2AB2067DA16AE8731' -e'ls'0x4266680x4266680x428f30open_camera_dev: ptp_opensession failed 0x2ff

0x428f30open_camera_dev: ptp_opensession 2 failed: 0x2ff

ERROR: /usr/share/chdkptp/lua/chdku.lua:103: attempt to index field 'ptpdev' (a nil value)
stack traceback:
        /usr/share/chdkptp/lua/chdku.lua:103: in function 'match_ptp_info'
        /usr/share/chdkptp/lua/cli.lua:1192: in function </usr/share/chdkptp/lua/cli.lua:1152>
        (tail call): ?
        (tail call): ?
        [C]: in function 'xpcall'
        /usr/share/chdkptp/lua/cli.lua:239: in function 'execute'
        /usr/share/chdkptp/lua/main.lua:188: in function 'do_execute_option'
        /usr/share/chdkptp/lua/main.lua:208: in function 'do_no_gui_startup'
        /usr/share/chdkptp/lua/main.lua:222: in main chunk
        [C]: in function 'require'
        [string "require('main')"]:1: in main chunk
ERROR: not connected
0x428c00open_camera_dev: ptp_opensession failed 0x2ff

0x428c00open_camera_dev: ptp_opensession 2 failed: 0x2ff

Any ideas? The code just opens two threads and runs CHDKPTP with an exec call in each of them, with arguments -e'connect -sSERIAL' -e'ls'. I'm using CHDK PTP from trunk, r303.

Re: CHDK PTP multiple instances
« Reply #1 on: 04 / October / 2012, 11:09:54 »
More information: the error with the multithreaded setup does not happen if I use the device and bus to connect. It happens only if I connect with the serial.

*

Offline reyalp

  • ******
  • 14126
Re: CHDK PTP multiple instances
« Reply #2 on: 04 / October / 2012, 21:26:17 »
Yes, this is a known issue. To get the serial, chdkptp has to connect to the camera. That means if it's already connected to another instance, it will be reset. Listing has the same problem, since it tries to display the serial.

Adding the ability to detect when a connection is in use and not reset it is on my TODO list.

In general, if you want to control multiple cameras, I'd suggest doing it from within a single instance of chdkptp. In this case, listing is OK because it re-uses any existing connection. This will require some lua code, you can see multicam.lua as an example. However, this does prevent you from doing actual data transfers in parallel, and makes waiting operations more complicated if you don't want to do them serially.

Note if you want to use CLI commands with multiple cameras, you can swap the 'con' global variable around without reconnecting, e.g:
Code: [Select]
___> !devs=chdk.list_usb_devices()
___> !con1=chdku.connection(devs[1])
___> !return con1:connect();
=true
___> !con2=chdku.connection(devs[2])
___> !return con2:connect()
=true
___> list
+1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=923D25F5C8854118BA3DF6090C5F4E57
+2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
___> !con=con1
con> list
*1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=923D25F5C8854118BA3DF6090C5F4E57
+2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
con> !con=con2
con> list
+1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=923D25F5C8854118BA3DF6090C5F4E57
*2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
con>
The * indicates the camera currently connected and selected for the CLI by the 'con' variable. The + indicates a camera that is connected, but not selected for the CLI.
Don't forget what the H stands for.

Re: CHDK PTP multiple instances
« Reply #3 on: 13 / September / 2013, 14:05:25 »
Hello, I am running a 50-camera setup with CHDK, and I was having some sychronization issues with my rig. I was asking for help here in the forum, but then I stumpled upon this thread.

I am using an Arduino that triggers all the cameras, the exposure parameters are read from the SD-Cards as setups. Now before trying to improve the synchronization of my cameras with the CHDK USB remote function, I would like to find out if it would be better to start from scratch, not using an Arduino any more but to connect all the cameras via USB to a single PC. That would be a great step forward for me, because at the moment I have to take out the cards from the camera, put them into a card reader, read the images and so on. Also I could adjust all exposure parameters from a single place, if I manage to connect all cameras to chdkptp and trigger them by the computer.

So I bought some USB-Hubs, at the moment I have stacked one Hub into another one that is connected to a notebook. The two SX200IS are connected at the end. I managed to switch between them using the method described here (!con=conX) and trigger the cameras one by one.

This is quite exciting for me, but now I wonder how to make the cameras shoot at once. Is there a way to bring the camera into a "ready-to-shoot"-mode, like the one I have when applying 5 Volt to the Y-cable I use together with CHDKs USB remote function. And then fire them all at once or with a very short delay?

Do you have any suggestions how to achieve a multi-camera-shooting with chdkptp?

I have also skills to build special gear for such a thing, I am able to program Arduinos and can solder relais together to maybe physically disconnect cameras from the Y-cable and connect them to the Hubs, or vice versa.

I appreciate any proposals very much! Thanks! Martin

*

Offline reyalp

  • ******
  • 14126
Re: CHDK PTP multiple instances
« Reply #4 on: 13 / September / 2013, 17:31:14 »
Now before trying to improve the synchronization of my cameras with the CHDK USB remote function, I would like to find out if it would be better to start from scratch, not using an Arduino any more but to connect all the cameras via USB to a single PC.
Controlling shooting with PTP rather than the USB remote will give much worse sync. USB remote is a very low level electrical signal, without involving all the PTP and USB protocol overhead.

Quote
That would be a great step forward for me, because at the moment I have to take out the cards from the camera, put them into a card reader, read the images and so on. Also I could adjust all exposure parameters from a single place, if I manage to connect all cameras to chdkptp and trigger them by the computer.
I believe that nafraf create a hybrid system for his rig, where he uses chdkptp for configuration, upload and download but USB remote for shooting: http://chdk.setepontos.com/index.php?topic=10220.0

Quote
This is quite exciting for me, but now I wonder how to make the cameras shoot at once. Is there a way to bring the camera into a "ready-to-shoot"-mode, like the one I have when applying 5 Volt to the Y-cable I use together with CHDKs USB remote function. And then fire them all at once or with a very short delay?

Do you have any suggestions how to achieve a multi-camera-shooting with chdkptp?
You can do this using the multicam.lua module included with chdkptp (it's not really finished, some coding may be required), but the synchronization will be not be very good compared to a properly functioning USB remote trigger, several tens of ms at best.

I've never tried it with more than two cameras. See http://chdk.setepontos.com/index.php?topic=6231.msg81330#msg81330 and comments in the source.
Don't forget what the H stands for.

Re: CHDK PTP multiple instances
« Reply #5 on: 13 / September / 2013, 19:29:42 »
Yes, that´s what I supposed. I already assumed that the sync would be the real problem. So I will build some special gear that unlinks all the cameras from the USB-trigger cable and then connects them to the USB-Bus. I tried that here by dis- and reconnecting the cameras from the hub, they are re-recognized flawlessly. It will not be that complicated, just a lot of soldering. I just tested with two cams, but I suppose it will work.

I ordered two Arduino MEGA 2560 that will address some optocouplers or relais while being connected to a PC too. this way I can upload/download images, exposure settings and all that, while still using chdkptp.

I don´t have the time to start that project now, but i will start it this year. Results will be posted here .

Best regards and thanks a lot!

Re: CHDK PTP multiple instances
« Reply #6 on: 15 / September / 2013, 01:26:49 »
Yes, this is a known issue. ...........
Adding the ability to detect when a connection is in use and not reset it is on my TODO list.


Attached is a possible solution when trying to connect to Multiple Cameras:-

CHDK PTP Multiple Instances 1; ... Shows hand crafted canon multiple camera drivers
for Windows Xp and Windows Blue [preview]

CHDK PTP Multiple Instances 2; ... Shows hand crafted canon multiple camera drivers
for a Ixus 125 and a Ixus 115.

Currently there is only a "Realitive" path to the cameras.
Also the standard drivers are "Randomised".

These drivers have a "Absolute" path to the cameras
keyed by VID, PID, and iSerial Number, Each Camera can also have a unique "Label"

Also there is a known GUID ........"{F00000-0125-000................... for Ixus 125
And Also there is a known GUID.."{F00000-0115-000................... for Ixus 115

This is a Reliable and Repeatable way to connect to multiple Cameras.
Additionally the "AutoPlay", AutoRun" or "Events" system's can be used
to do "Something" when a  iSerial Number camera is "Connected" or "DisConnected"

The cameras are listed in  iSerial Number order in this demo.

H-H

Re: CHDK PTP multiple instances
« Reply #7 on: 15 / September / 2013, 10:52:58 »
Yes, that´s what I supposed. I already assumed that the sync would be the real problem. So I will build some special gear that unlinks all the cameras from the USB-trigger cable and then connects them to the USB-Bus. I tried that here by dis- and reconnecting the cameras from the hub, they are re-recognized flawlessly. It will not be that complicated, just a lot of soldering. I just tested with two cams, but I suppose it will work.

I ordered two Arduino MEGA 2560 that will address some optocouplers or relais while being connected to a PC too. this way I can upload/download images, exposure settings and all that, while still using chdkptp.

I don´t have the time to start that project now, but i will start it this year. Results will be posted here .

Best regards and thanks a lot!

Sounds great, but where I get confused [and apologies for the possible ignorance of my post, but I still don't have any cams to experiment with  :(] with this is reyalp's reply#5 at http://chdk.setepontos.com/index.php?topic=10687.0:

[edit: reply #5 is here http://chdk.setepontos.com/index.php?topic=10687.msg105196#msg105196 ]

"...Additionally, if you are triggering the camera with the "USB remote" functionality (using the usb +5v signal to trigger shots), you cannot combine this with any USB protocol communication. USB remote hides the status of the USB power bit from the rest of the firmware."

So, if:

step (i) chdkptp/usb hubs are used to setup the cameras
and then
step (ii) the switch disconnects the usb hubs/chdkptp in prep for chdk usbremote shutter trigger

Query => will the chdkptp disconnection not corrupt / destroy the camera setup before the chdk usbremote triggers the camera shutters ?

I assume step

(iii) is to throw the switch back to re-connect the usb hubs/chdkptp to enable image download.

I'd also appreciate instruction how to retrieve the url of a specific post [rather than the page of the post]  :-[
« Last Edit: 01 / October / 2013, 14:19:56 by andrew.stephens.754365 »

Re: CHDK PTP multiple instances
« Reply #8 on: 15 / September / 2013, 12:50:07 »
Sounds great, but where I get confused [and apologies for the possible ignorance of my post, but I still don't have any cams to experiment with  :(] with this is reyalp's reply#5 at http://chdk.setepontos.com/index.php?topic=10687.0:

"...Additionally, if you are triggering the camera with the "USB remote" functionality (using the usb +5v signal to trigger shots), you cannot combine this with any USB protocol communication. USB remote hides the status of the USB power bit from the rest of the firmware."

So, if:

step (i) chdkptp/usb hubs are used to setup the cameras
and then
step (ii) the switch disconnects the usb hubs/chdkptp in prep for chdk usbremote shutter trigger

Query => will the chdkptp disconnection not corrupt / destroy the camera setup before the chdk usbremote triggers the camera shutters ?

I assume step

(iii) is to throw the switch back to re-connect the usb hubs/chdkptp to enable image download.
Reading through this thread and the others linked from it,  it's not clear to me how nafraf gets all his cameras to enable/disable the USB remote functionality locally so that PTP communications can be used interchangably with CHDK USB remote 5V sync?    But then nafraf has done quite a bit of CHDK porting work and is quite capable of spinning a custom version to support that I guess?

Quote
I'd also appreciate instruction how to retrieve the url of a specific post [rather than the page of the post]  :-[
Same way you do with any link on a web page.  With Google's Chrome browser,  you point your mouse at the title text of the post that interest you, right click and select "Copy Link Address".
« Last Edit: 15 / September / 2013, 12:53:02 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: CHDK PTP multiple instances
« Reply #9 on: 15 / September / 2013, 12:57:21 »
it's not clear to me how nafraf gets all his cameras to enable/disable the USB remote functionality locally so that PTP communications can be used interchangably with CHDK USB remote 5V sync?
A guess: CHDK is able to mask the USB bit. If you know for sure that USB data connection is available, you could set/unset the USB bit independently from the hardware... It's just not a CHDK feature yet.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal