Skip to main content
PTP referencePTP reference

Look up any PTP code Slate knows: what it means, how its value is laid out, and which Camera method or setting uses it. The pages are generated from Slate's own definitions, so they match what the code sends.

You do not need this reference to use Slate: Camera covers every supported operation by name. Use it when you read a protocol trace, see a raw code in an error, or send commands yourself. New to the protocol? Start with What is PTP?.

Find a code

Slate has drivers for Sony, Canon and Nikon. For Fujifilm, Panasonic, Olympus, Leica and Sigma, these are the codes Slate knows by name: a camera from any other brand opens with the standard PTP driver, which sends none of them. See Other brands.

Have only a number from a trace or an error? The PTP code lookup lists all 532 codes in numeric order, with every maker's meaning of each.

Also: Datatypes · Vendor IDs · Datasets · Types

Each kind of code has its own range, so a code's first digit usually says what it is:

KindCodes
Operation0x1000–0x1fff standard, 0x9000–0x9fff vendor
Response0x2000–0x2fff standard, 0xa000–0xafff vendor
Format0x3000–0x3fff standard, 0xb000–0xbfff vendor
Event0x4000–0x4fff standard, 0xc000–0xcfff vendor
Property0x5000–0x5fff standard, 0xd000–0xdfff vendor

Vendor codes overlap between makers, which is why each maker has its own pages. A few codes sit outside these ranges: the MTP object-property operations (0x9801–0x9805) are listed with the standard operations, Sony has properties at 0xe0xx, and some Nikon properties have 32-bit codes from 0x1d000, read with GetDevicePropDescEx.

Send a command yourself

Raw commands go through protocolSession(camera), which shares the camera's open session. See Protocol access.

import { Camera } from '@darkgrade/slate'
import {
    genericOperationRegistry,
    protocolSession,
} from '@darkgrade/slate/protocol'

const camera = new Camera()
await camera.connect()

const session = protocolSession(camera)
const reply = await session.send(genericOperationRegistry.GetDeviceInfo, {})
console.log(reply.code, reply.data)

The pieces

Operations

An operation is one command from the computer to the camera: an operation code and up to five parameters, an optional data phase in one direction, then a response code with up to five parameters. GetDeviceInfo asks the camera what it is; GetObject downloads a file.

Responses

A response code ends every operation. OK is 0x2001; anything else says why the operation did not happen. See Standard responses.

Properties

A device property is one numbered value on the camera, such as ISO or battery level. GetDevicePropDesc describes one (its datatype, current value and allowed values) as a DevicePropDesc; GetDevicePropValue and SetDevicePropValue read and write it. Makers add their own operations for their own properties.

Events

An event is a message the camera sends on its own: ObjectAdded when a file is written, DevicePropChanged when a setting changes. Each carries up to three parameters.

Formats

An object format code says what kind of file an object is: a JPEG, a movie, a folder. See Standard formats.

Datatypes

A datatype code says how a value is laid out in bytes: signed and unsigned integers of 8 to 128 bits, arrays of them, and strings. See Datatypes.

Datasets

A dataset is a structured block of bytes in an operation's data phase. Slate decodes each one into an object.

DatasetWhat it holds
VariableValueA value whose layout depends on a datatype code, as the default, current and allowed values of a DevicePropDesc are.
DeviceInfoWhat a camera says about itself: its model, firmware version, and the operations, events, properties and formats it supports.
DevicePropDescOne device property described in full: its datatype, access, current and default value, and the values the camera accepts now.
ObjectInfoOne object on the card described: its format, size, pixel dimensions, file name, capture date and parent folder.
StorageInfoOne store described (a memory card): its capacity, free space in bytes and in images, and its label.

Vendor datasets (12)

Types

The TypeScript shapes the definitions are written in: codec, datatype, event, format, operation, parameter, property, response, type-helpers.

Identifiers

Parameters with these names mean the same thing in every operation and event.

StorageID

A uint32 that names one store on the camera, such as a memory card. GetStorageIDs lists the valid ones and GetStorageInfo describes one as a StorageInfo. StoreAdded and StoreRemoved carry the StorageID of a store that was added or removed. Where an operation filters by store, 0xFFFFFFFF means all stores. In Slate, getCardStatus() reads the stores for you.

ObjectHandle

A uint32 that names one object on the camera: a photo, a clip or a folder. GetObjectHandles lists them, GetObjectInfo describes one as an ObjectInfo, and GetThumb, GetObject and GetPartialObject read its bytes. ObjectAdded carries the handle of a new file. An ObjectInfo's parentObject is the handle of the folder it is in. In Slate, listMedia() and downloadMedia() do this for you.

ObjectFormatCode

A format code used as a filter or a description: GetObjectHandles takes it as an optional filter (default 0), and an ObjectInfo carries its object's format as objectFormat.

DevicePropCode

The code of a device property: one from the standard properties or from the camera maker's own pages. DevicePropChanged carries the code of the property that changed.

SessionID and TransactionID

OpenSession starts a session with a SessionID the computer chooses; every operation after it is one transaction, numbered by a TransactionID that the data phase and the response repeat. Slate opens the session in connect() and numbers transactions for you.

⌘I