-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,18 +75,16 @@ | |
<div class="headertitle"><div class="title">camlib </div></div> | ||
</div><!--header--> | ||
<div class="contents"> | ||
<div class="textblock"><p><a class="anchor" id="md_README"></a>This is a portable PTP/USB library written in C99. This isn't a fork of gphoto2, libptp, or libmtp. <br /> | ||
This is a complete rewrite from the ground up, and is written to be fast and portable. <br /> | ||
</p> | ||
<p><a href="https://danielc.dev/camlib/">You can read the latest up-to-date documentation here.</a></p> | ||
<div class="textblock"><p><a class="anchor" id="md_README"></a>This is a portable Picture Transfer Protocol (PTP) library written from scratch in C.</p> | ||
<p><a href="https://danielc.dev/camlib/">Documentation</a></p> | ||
<h1><a class="anchor" id="autotoc_md1"></a> | ||
Design</h1> | ||
<ul> | ||
<li>Data parsing, packet building, and packet sending/recieving is all done in a single buffer</li> | ||
<li>Will not perform memory allocations between operations (constant high memory usage)</li> | ||
<li>No platform specific code at the core</li> | ||
<li>Data parsing, packet building, and packet sending/recieving is all done in a single buffer (grows as needed)</li> | ||
<li>Will not perform memory allocations between operations</li> | ||
<li>Portable, works well on many different platforms</li> | ||
<li>No macros, only clean C API - everything is a function that can be accessed from other languages</li> | ||
<li>I'm writing this while writing <a href="[email protected]:petabyt/vcam.git">vcam</a> at the same time, so my vendor opcode implementations are (IMO) more reliabile than others</li> | ||
<li>I'm writing this while writing <a href="[email protected]:petabyt/vcam.git">vcam</a> at the same time, so my vendor opcode implementations are (maybe) more reliabile than others ;)</li> | ||
</ul> | ||
<h1><a class="anchor" id="autotoc_md2"></a> | ||
Checklist</h1> | ||
|
@@ -99,9 +97,8 @@ <h1><a class="anchor" id="autotoc_md2"></a> | |
<li>[x] ISO PTP/IP implementation</li> | ||
<li>[x] <strike>Fuji WiFi and USB support</strike> (code moved to <a href="https://github.com/petabyt/fudge/">https://github.com/petabyt/fudge/</a>)</li> | ||
<li>[x] Lua bindings (for embedding)</li> | ||
<li>[x] <a href="[email protected]:clutchlink/camlibjs.git">Javascript bindings</a> (for browser)</li> | ||
<li>[ ] Complete thread safety (almost there)</li> | ||
<li>[ ] Complete unit tests</li> | ||
<li>[x] (Mostly) thread safe</li> | ||
<li>[x] Regression testing (vcam)</li> | ||
<li>[ ] Sony support</li> | ||
<li>[ ] Pentax support</li> | ||
</ul> | ||
|
@@ -110,23 +107,22 @@ <h1><a class="anchor" id="autotoc_md3"></a> | |
<p>Get device info: </p><div class="fragment"><div class="line">#include <camlib.h></div> | ||
<div class="line"> </div> | ||
<div class="line">int main() {</div> | ||
<div class="line"> struct PtpRuntime r;</div> | ||
<div class="line"> ptp_init(&r);</div> | ||
<div class="line"> struct PtpRuntime *r = ptp_new(PTP_USB);</div> | ||
<div class="line"> </div> | ||
<div class="line"> if (ptp_device_init(&r)) {</div> | ||
<div class="line"> if (ptp_device_init(r)) {</div> | ||
<div class="line"> printf("Device connection error\n");</div> | ||
<div class="line"> return 0;</div> | ||
<div class="line"> }</div> | ||
<div class="line"> </div> | ||
<div class="line"> struct PtpDeviceInfo di;</div> | ||
<div class="line"> </div> | ||
<div class="line"> char buffer[2048];</div> | ||
<div class="line"> ptp_get_device_info(&r, &di);</div> | ||
<div class="line"> ptp_get_device_info(r, &di);</div> | ||
<div class="line"> ptp_device_info_json(&di, buffer, sizeof(buffer));</div> | ||
<div class="line"> printf("%s\n", buffer);</div> | ||
<div class="line"> </div> | ||
<div class="line"> ptp_device_close(&r);</div> | ||
<div class="line"> ptp_close(&r);</div> | ||
<div class="line"> ptp_device_close(r);</div> | ||
<div class="line"> ptp_close(r);</div> | ||
<div class="line"> return 0;</div> | ||
<div class="line">}</div> | ||
</div><!-- fragment --><p> Calling a custom opcode: </p><div class="fragment"><div class="line">// Send a command, and recieve packet(s)</div> | ||
|
@@ -146,14 +142,14 @@ <h1><a class="anchor" id="autotoc_md3"></a> | |
<div class="line">uint32_t dat[2] = {123, 123};</div> | ||
<div class="line">return ptp_send_data(r, &cmd, dat, sizeof(dat));</div> | ||
</div><!-- fragment --><p> Explore the filesystem: </p><div class="fragment"><div class="line">struct UintArray *arr;</div> | ||
<div class="line">int rc = ptp_get_storage_ids(&r, &arr);</div> | ||
<div class="line">int rc = ptp_get_storage_ids(r, &arr);</div> | ||
<div class="line">int id = arr->data[0];</div> | ||
<div class="line"> </div> | ||
<div class="line">rc = ptp_get_object_handles(&r, id, PTP_OF_JPEG, 0, &arr);</div> | ||
<div class="line">rc = ptp_get_object_handles(r, id, PTP_OF_JPEG, 0, &arr);</div> | ||
<div class="line"> </div> | ||
<div class="line">for (int i = 0; i < arr->length; i++) {</div> | ||
<div class="line"> struct PtpObjectInfo oi;</div> | ||
<div class="line"> ptp_get_object_info(&r, arr->data[i], &oi);</div> | ||
<div class="line"> ptp_get_object_info(r, arr->data[i], &oi);</div> | ||
<div class="line"> printf("Filename: %s\n", oi.filename);</div> | ||
<div class="line">}</div> | ||
<div class="line"> </div> | ||
|