diff --git a/docs/c.md b/docs/c.md index b670d8e..e55e7ec 100644 --- a/docs/c.md +++ b/docs/c.md @@ -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);` diff --git a/docs/camlib.md b/docs/camlib.md index cff96fd..820e0e0 100644 --- a/docs/camlib.md +++ b/docs/camlib.md @@ -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. @@ -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 ``` + diff --git a/docs/ptp.md b/docs/ptp.md new file mode 100644 index 0000000..99ff3f8 --- /dev/null +++ b/docs/ptp.md @@ -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