supplierdeeply

Technical aspects of multi-camera PTP communication.

  • 16 Replies
  • 2479 Views
Technical aspects of multi-camera PTP communication.
« on: 14 / January / 2014, 11:08:50 »
Advertisements
These questions will be rather specialised so I suspect only reyalp or mweerden will be able to respond.

In order to understand PTP I am playing with ptpcam.

As a very dirty temporary hack I am using sdmcon -l to execute my code.

Let us see if I understand this  .........

sdmcam communicates with all the devices on all the buses using endpoint zero of device address zero.

A pointer is provided to the first of a linked-list of bus structures.
Each bus structure contains a pointer to the first of a linked-list of device structures.
The device structures contain pointers to other structures, etc.

So, we enumerate all devices on all buses, ignoring hubs and devices that do not support PTP.

For each device we obtain the input, output and interrupt endpoints and then call a function to initialise our local params,ptp_usb and dev structures.
A session is opened and structure deviceinfo populated with appropriate data.

We can then display any of the information in those structures.

Now, let us query if a certain command is supported :-

result = ptp_operation_issupported(&params, PTP_OC_InitiateCapture);

We are passing a pointer to our local params structure that was instantiated previously.

The code compiles but the camera crashes at that point when sdmcon -l is executed.

Any idea why ?

It is something to do with pointers to a structure and its members.

ptp_operation_issupported() simply scans the deviceinfo.OperationsSupported[] array for a match.

deviceinfo is a separate local PTPDeviceInfo structure that is also in a local PTPParams structure.

In the called function it is referred to as params->deviceinfo.OperationsSupported, as expected, except it causes the crash.

So, how would we refer to the deviceinfo structure and its members in the called function ptp_operation_issupported(&params, PTP_OC_InitiateCapture) ?
« Last Edit: 14 / January / 2014, 12:40:08 by Microfunguy »

Re: Technical aspects of multi-camera PTP communication.
« Reply #1 on: 14 / January / 2014, 12:20:51 »
[deleted]

« Last Edit: 14 / January / 2014, 12:38:35 by Microfunguy »

*

Offline reyalp

  • ******
  • 11491
Re: Technical aspects of multi-camera PTP communication.
« Reply #2 on: 16 / January / 2014, 22:43:53 »
As a very dirty temporary hack I am using sdmcon -l to execute my code.
what is sdmcon?
Quote
The code compiles but the camera crashes at that point when sdmcon -l is executed.

Any idea why ?
No, not nearly enough information.

If the camera crashes, check the romlog on the camera. If that isn't informative, you can try to do a process of elimination or throw debug prints in your ptp code to narrow down exactly where it crashes.

Quote
It is something to do with pointers to a structure and its members.
Since the camera crashes, I would question this conclusion. Again, the first step would be to find out which specific PTP command triggers the crash.
« Last Edit: 16 / January / 2014, 23:16:58 by reyalp »
Don't forget what the H stands for.

*

Offline msl

  • *****
  • 1237
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Technical aspects of multi-camera PTP communication.
« Reply #3 on: 17 / January / 2014, 04:21:57 »
what is sdmcon?
A clone of chdkptp & ptpCamGui designed with Autoit, like ever without of any informations about the sources.

msl
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!


Re: Technical aspects of multi-camera PTP communication.
« Reply #4 on: 17 / January / 2014, 06:23:00 »
what is sdmcon?

Like your chdkptp, it is simply a test command-line programme based on ptpcam.
It is for my own use, has not been released (even for testing) and is not officially supported.
The only time it was mentioned in the forum was to state that it would not be officially available or supported because it would create too much work.

Anyway, I have started a new programme for multicamera communication.
That is multicam.exe.

It enumerates all connected devices and creates a linked-list of structures containing pointers to bus and dev structures.

At present. it then simply walks the linked-list and opens and closes a session with each camera in turn.


Can we open multiple sessions or do we have to open a session, send the operational command, close the session and then repeat for the other cameras ?

« Last Edit: 17 / January / 2014, 08:27:43 by Microfunguy »

*

Offline reyalp

  • ******
  • 11491
Re: Technical aspects of multi-camera PTP communication.
« Reply #5 on: 17 / January / 2014, 17:02:01 »
Can we open multiple sessions or do we have to open a session, send the operational command, close the session and then repeat for the other cameras ?
You can do either. Connecting / disconnection is likely to be a bit slower.

chdkptp already supports having connections open to multiple cameras. It maintains a separate PTPParams and PTP_CON_STATE (equivalent to PTP_USB in the ptpcam code) for each connection.

chdkptp keeps a table of these as device/bus pairs, since powershots only support one PTP session per camera. chdk_connection() either creates or retrieves these as needed.
Don't forget what the H stands for.

Re: Technical aspects of multi-camera PTP communication.
« Reply #6 on: 17 / January / 2014, 17:43:47 »
chdkptp already supports having connections open to multiple cameras. It maintains a separate PTPParams and PTP_CON_STATE (equivalent to PTP_USB in the ptpcam code) for each connection.

These are the dynamically-allocated ptp_cs objects that include a PTP_USB structure and also timeout and connection-state info ?
The usb time-out is a #define anyway, why is it in ptp_cs ?

I see the connection state allows for the possibility of TCP.

I see the params structure can contain the addresses of usb or tcp functions.
It also contains a pointer to the ptp_cs object as well as a handle to   ........... ?
I was thinking a single params would work as long as the data member was changed to the current ptp_cs object.

I guess not, my code crashes.

I assumed the handle would be updated when the session was opened.
Hmmm ........... I guess it is overriden by each connection, hence the need for unique versions.


Re: Technical aspects of multi-camera PTP communication.
« Reply #7 on: 17 / January / 2014, 19:47:19 »
Just to be clear, for each camera and using the corresponding PTPParams and PTP_USB structures, we can open a session with each camera.

The code can then enter an endless loop waiting for user input.

When a command such as 'shoot' is entered, it is handled by the single-camera code and the operation command is automatically sent to all connected cameras ?

I guess that I need to create arrays of PTPParams and PTP_USB structures.

Initially, I do not need to index them by a bus/dev key.
« Last Edit: 17 / January / 2014, 21:59:33 by Microfunguy »


*

Offline reyalp

  • ******
  • 11491
Re: Technical aspects of multi-camera PTP communication.
« Reply #8 on: 17 / January / 2014, 22:08:29 »
Just to be clear, for each camera and using the corresponding PTPParams and PTP_USB structures, we can open a session with each camera.
Yes.
Quote
When a command such as 'shoot' is entered, it is handled by the single-camera code and the operation command is automatically sent to all connected cameras ?
I'm not really clear what you are asking about.

At the PTP level, each connection is connected to a single camera, so PTP functions can only be called on an individual camera, and the entire program waits for any PTP call to complete.

The normal chdkptp CLI (which implements commands like 'shoot') also has a single "current" connection, stored the global variable con.

The chdkptp Lua API lets you open and operate on as any number of connections. If you have multiple connections opened using the API, you can switch the active CLI connection just by assigning to the con variable.

The multicam.lua module is an example of using multiple connections in the API. It allows you to perform the same operation on multiple cameras using a single command. This module was mostly a proof of concept, it isn't used by the normal chdkptp commands. Example usage is included in a comment at the top of the file.
Don't forget what the H stands for.

Re: Technical aspects of multi-camera PTP communication.
« Reply #9 on: 19 / January / 2014, 18:35:32 »
Thanks, I understand.

It seems that I have implemented something similar.

In the command loop I can open any camera and execute all the normal commands, including one that switches to a chosen camera.

My old AutoIt programme can send commands directly to the programme, including the one to switch cameras.
In addition, AutoIt can execute a list of commands that are in a text file.
I had forgotten that I had developed that, will test it tomorrow.

 

Related Topics