Skip to content

Commit

Permalink
document ptp/ip stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Jan 4, 2024
1 parent a050012 commit 71f13dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This means that functions processing or using this data *must* keep the operatio
the caller isn't making the application thread-safe. In a single-threaded application, there is no need for it to be thread-safe.

Camlib was designed to run on a single thread, through a thread-safe server returning `bind` requests. This works well
in many applications, but I'm slowly working on making it thread-safe for higher speeds applications.
in many applications, but I'm slowly working on making it thread-safe for more complicated appliations.

## `void ptp_generic_init(struct PtpRuntime *r);`
## `void ptp_init(struct PtpRuntime *r);`
Initializes a `struct PtpRuntime`. The struct is pretty small. This allocates the a large buffer to `r.data`.
You may also set r.connection_type to one of `enum PtpConnType`.
## `int ptp_device_init(struct PtpRuntime *r);`
Expand Down
15 changes: 1 addition & 14 deletions docs/camlib.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Documentation For Camlib
- PDF Reference for PTP and MTP: https://www.usb.org/document-library/media-transfer-protocol-v11-spec-and-mtp-v11-adopters-agreement
- Documentation for [CamControl scripting](https://camcontrol.danielc.dev/docs/)

## Quick Overview of PTP Standard
### To issue a command to the device
1. Send a *command packet* with up to 5 parameters
2. An optional data packet (the data phase)
3. A response packet(s) is recieved from the camera.

For data to be sent to the camera, a data packet can be sent following
the command packet. The camera should know when to expect this.

- Each packet sent to the camera has a unique transaction ID (see PtpBulkContainer.transaction)
- The operation code (OC) is an ID for each command, and determines how the camera will expect and send back data.
- In a response packet, the response code (RC) is placed in the PtpBulkContainer.code field

## JSON Bindings
Camlib provides a JSON frontend that can easily be ported to higher level programming languages,
like Java, Javascript, or Python.
Expand All @@ -40,3 +26,4 @@ ptp_custom_send;4097,66,66,66,66,66;
ptp_custom_cmd;4097,1,2,3,4,5
ptp_set_property;"iso",6400
```

35 changes: 35 additions & 0 deletions docs/ptp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Documentation For Camlib
- PDF Reference for PTP and MTP: https://www.usb.org/document-library/media-transfer-protocol-v11-spec-and-mtp-v11-adopters-agreement
- PTP/IP has no free public reference :(

Terminology:
- initiator: the computer that sends commands (laptop, phone, PC)
- responder: the computer that responds to commands (the camera)

## Quick Overview of PTP Standard
### To issue a command to the device
1. Send a *command packet* with up to 5 parameters
2. An optional data packet (the data phase)
3. A response packet(s) is recieved from the camera.

For data to be sent to the camera, a data packet can be sent following
the command packet. The camera should know when to expect this.

- Each packet sent to the camera has a unique transaction ID (see PtpBulkContainer.transaction)
- The operation code (OC) is an ID for each command, and determines how the camera will expect and send back data.
- In a response packet, the response code (RC) is placed in the PtpBulkContainer.code field

## PTP/IP
PTP/IP is the variant of PTP designed to be used on TCP.

A standard request to the responder is as follows:
1. Command request (`PTPIP_COMMAND_REQUEST`) send to responder
2. If sending data payload:
- Set the `data_phase` field in the initial `PTPIP_COMMAND_REQUEST` packet
- Send data start packet (`PTPIP_DATA_PACKET_START`), contains data length
- Send data end packet (`PTPIP_DATA_PACKET_END`), which includes the actual data
2. If not sending payload to responder, then, wait for response

Response is either:
- `PTPIP_DATA_PACKET_START` packet followed by `PTPIP_DATA_PACKET_END`, and finally a `PTPIP_COMMAND_RESPONSE` packet
- Just a `PTPIP_COMMAND_RESPONSE` packet

0 comments on commit 71f13dc

Please sign in to comment.