Wikia

CHDK Wiki

Watchlist Recent changes

PTP Extension

The Picture Transfer Protocol (PTP) facilitates remote operations on a camera connected computer. Typical operations are uploading/downloading photos and remote captures.

Most cameras support some basic operations over PTP, but often only in a limited fashion. For example, downloading of files can be limited to just JPEG files.

The PTP extension for CHDK discussed in this article is does not alter the standard operations but adds new CHDK-specific operations instead. This is due to the complexity involved in altering or complete overwriting the standard operations. It also means that special tools are required to access this new functionality.

The CHDK extension was first added to the CHDK trunk in changeset 957, and has been enabled for all cameras since changeset 1116

Related forum thread: [1]

Contents

Functionality Edit

An overview of the functionality available through the PTP interface is described below. The specific functionality and usage depends on which client application you use. The canonical reference to the CHDK PTP protocol is core/ptp.h in the CHDK source tree.

File transferEdit

Files can be uploaded to and downloaded from any part of the file system.

Script executionEdit

The PTP interface allows execution of lua scripts sent over PTP. In general, any scripting function available to normal CHDK scripts can be executed remotely. There are some additional functions specific to PTP, described in Lua/PTP Scripting.

Some of the features available using Lua scripts include

  • Switch to and from record mode
  • Switch recording modes, e.g. Av, Tv, Video
  • Adjust exposure parameters, focus, zoom etc.
  • Shoot pictures or video
  • Manipulate Canon menus and settings with simulated key presses
  • List, create and delete files and directories
  • Return values from script, send and receive arbitrary messages between the camera and PC
  • Shutdown or reboot the camera

Debugging featuresEdit

  • Read and write camera memory
  • call arbitrary camera functions

LibUSB driver for windows Edit

All the client applications below require libusb-win32 driver on windows. Available for Windows 2000, Windows XP 32 Bit, Windows Vista 32/64 Bit, Windows 7 32/64 Bit.

1. Extract archive.

2. Connect camera via USB and turn on in play mode.

3. Search in extracted archive in subdirectory for inf_wizard.exe and run this file.

4. Select in the second window 'Device Selection' your camera.

5. The driver will be provided and installed.

6. No PC reboot is needed.

Client applications Edit

As described above, a client program compatible that implements the CHDK protocol is required to access these features

ptpcamEdit

The original source as well as the proposal consist of both a patch for the SVN trunk and a patch for the ptpcam program. The latter adds an option --chdk with starts an interactive prompt to communicate with the connected camera.

A version of ptpcam is maintained in the chdkde source tree, with builds available from the chdkde forum.

ptpcam may be built for Windows or Linux.

ptpCamGuiEdit

ptpCamGui is a graphical front end for ptpcam. Builds are available from the chdkde forum It's also part of CHDK Shell.

A forum thread including descriptions can you find here.

The source code for the frontend and the DLL is available on the ptpCamGui assembla project.

ptpCamGui is only available for Windows.

chdkptpEdit

chdkptp is a new client under development. It is currently in a pre-alpha state, but is usable as a replacement for ptpcam.

Source and builds can be found on the chdkptp assembla project. A thread in the chdk forum is available for discussion.

chdkptp provides a lua API to the CHDK protocol on the PC. A CLI and optional GUI based on IUP are implemented in lua. This allows easy customization, and enables end users to quickly implement complex interactions with code on the camera.

chdkptp is compatible with windows and linux.

chdkcam (historical)Edit

CHDKCAM is a Windows program that provides a graphical interface to the camera and also allows live streaming of the camera's screen. The CHDKCAM binaries should also be compatible with the adapted ptpcam from the original source.

CHDKCAM is only compatible with early development versions of the protocol, it is not compatible with the current CHDK or CHDKDE builds.

Usage notes Edit

Windows Edit

In order to get CHDKCAM or ptpcam to work properly you might need to disable the "Canon Camera Access Library" service (or, if that doesn't work, the "WIA" service).

Linux Edit

Make sure you've got access to USB; in some cases this means switching to root (or changing permissions).

Development details Edit

Also see the original documentation and the forum thread.

FAQ Edit

  • Download/upload fails with code 0x2ff or the camera crashes when you try to transfer a file
Perhaps you didn't correctly specify the file on the camera. Always use the full path and start with a capitalised 'A'. For example: "download A/DCIM/100CANON/IMG_1234.jpg test.jpg"
note this mainly applies to ptpcam, chdkptp corrects the names for you.
  • The canon firmware does not recognize key presses (real or from script) when PTP is connected
There are two known workarounds:
  • Switch to record mode using switch_mode_usb script function. Keys will still be enabled if you switch back to play.
  • On many DryOS cameras, post_levent_to_ui(4484) will also unlock the keys.


Adding support for another camera/firmware version (historical) Edit

note the following is for historical reference only. PTP is implemented in all complete CHDK ports now. As with CHDK itself it is usually a good idea to base your efforts on the sources of a similar camera. The essential steps to get any CHDK PTP support are as follows.

  • Find the add_ptp_handler function for your firmware.
  • Make sure init_chdk_ptp is started as a task.

This should enable you to connect with ptpcam --chdk and download/upload files, read/write memory and execute remote functions as well as Lua code.

Next you probably want to find a way to switch the camera to record mode (and back to playback mode). How to do this depends on the camera, so you probably need to check your reference source for this.

Finally you might want to add specific functions like those needed for CHDKCAM.

Functionality Comparison (historical) Edit

The various variants (original source, CHDKCAM, proposal for addition to trunk) of the CHDK PTP extension support the following functionality.

current trunk original CHDKCAM proposal
file upload/download x x x x
memory read/write x x x x
remote function calls x x x x
mode switching L x x
Lua code execution x x x x
retrieval of props and params L x x
camera shutdown/reboot L x
directory reading L x
script output retrieval L1 x
video settings x
versioning x x

L=functionality available using Lua

1 script error messages are returned and scripts can send arbitrary data, but console output is not returned.

Note that the proposal has much less extensions as the idea is to keep CHDK PTP as small as possible and provide the rest of the functionality (e.g. mode switching, shutdown/reboot) via scripting.

Availability (historical versions) Edit

The proposal version, with some minor modifications, has been included in CHDK trunk since changeset 957

At mweerden's github one can find the original sources as well as a follow-up attempt at a minimal version for inclusion in the SVN trunk. At ewavr's site you can find his CHDKCAM program and binaries for various firmwares.

Below is an overview of the currently supported firmwares. Here "cc" means there is a CHDKCAM version, "mg" it's supported in mweerden's code, "(b)" that there is a binary, "(s)" that it's in the source and "(p)" that there is a patch.

A480 1.00b cc (b)
A540 1.00b cc (p)
A570 1.00e mg (bp)
1.01a mg (bp)
A590 1.00e cc (b)
1.01b cc (b)
A610 1.00d cc (b)
1.00e cc (b)
1.00f cc (b)
A650 1.00d SVN (p)
A710 1.00a cc (b)
A720 1.00c cc (b)
G11 1.00j stubs
IXUS700IS/SD500 1.01a cc (b)
IXUS870IS/SD880 1.01a mg (s)
SX1 2.01a cc (b)
SX10 1.01a cc (b)
1.02b cc (b)
SX200IS 1.00c cc (b)

Pages on CHDK Wiki

Add a Page
496pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
746photos on this wiki
See more >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki