Skip to content

Commit

Permalink
add memberof PtpRuntime to most funcs, move docs link to main class
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Apr 12, 2024
1 parent aff4b76 commit 0c05030
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECT_NAME = "camlib"
PROJECT_BRIEF = "Documentation for camlib is still a work-in-progress"
INPUT = README.md docs/chdk.md docs/ml.md docs/ptp.md src/camlib.h
INPUT = README.md docs/chdk.md docs/ml.md docs/ptp.md src/camlib.h src/cl_ops.h
USE_MDFILE_AS_MAINPAGE = README.md
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# camlib
This is a Picture Transfer Protocol (PTP) library written in C.

[Documentation](https://danielc.dev/camlib/)
[Documentation](https://danielc.dev/camlib/structPtpRuntime.html)

## Design
- Data parsing, packet building, and I/O is all done in a single buffer (grows as needed)
@@ -19,7 +19,7 @@ This is a Picture Transfer Protocol (PTP) library written in C.
- [x] Camera liveviews
- [x] Implements most EOS/Canon vendor OCs
- [x] Optional lua bindings
- [x] (Mostly) thread safe
- [x] Thread safe (optional)
- [x] Regression testing (vcam)
- [ ] Sony support
- [ ] Pentax support
@@ -70,7 +70,7 @@ return ptp_send_data(r, &cmd, dat, sizeof(dat));
```
Explore the filesystem:
```
struct UintArray *arr;
struct PtpArray *arr;
int rc = ptp_get_storage_ids(r, &arr);
int id = arr->data[0];
free(arr);
20 changes: 20 additions & 0 deletions src/camlib.h
Original file line number Diff line number Diff line change
@@ -173,76 +173,96 @@ struct PtpArray {

/// @brief Returns the return code (RC) currently in the data buffer.
/// @note Not thread safe.
/// @memberof PtpRuntime
int ptp_get_return_code(struct PtpRuntime *r);

/// @brief Get number of parameters in packet in data buffer
/// @note Not thread safe.
/// @memberof PtpRuntime
int ptp_get_param_length(struct PtpRuntime *r);

/// @brief Get parameter at index i
/// @note Not thread safe.
/// @memberof PtpRuntime
uint32_t ptp_get_param(struct PtpRuntime *r, int i);

/// @brief Get transaction ID of packet in the data buffer
/// @note Not thread safe.
/// @memberof PtpRuntime
int ptp_get_last_transaction_id(struct PtpRuntime *r);

/// @brief Get ptr of packet payload in data buffer, after packet header
/// @note Not thread safe.
/// @memberof PtpRuntime
uint8_t *ptp_get_payload(struct PtpRuntime *r);

/// @brief Get length of payload returned by ptp_get_payload
/// @note Not thread safe.
/// @memberof PtpRuntime
int ptp_get_payload_length(struct PtpRuntime *r);

/// @brief Allocate new PtpRuntime based on bitfield options - see PtpConnType
/// @memberof PtpRuntime
struct PtpRuntime *ptp_new(int options);

/// @brief Reset all session-specific fields of PtpRuntime - both libusb and libwpd backends call
/// this before establishing connection, so calling this is not required
/// @memberof PtpRuntime
void ptp_reset(struct PtpRuntime *r);

/// @brief Init PtpRuntime locally - uses default recommended settings (USB)
/// @memberof PtpRuntime
void ptp_init(struct PtpRuntime *r);

/// @brief Frees PtpRuntime data buffer - doesn't free the actual structure, or device info (yet)
/// @memberof PtpRuntime
void ptp_close(struct PtpRuntime *r);

/// @brief Send a command request to the device with no data phase
/// @memberof PtpRuntime
int ptp_send(struct PtpRuntime *r, struct PtpCommand *cmd);

/// @brief Send a command request to the device with a data phase (thread safe)
/// @memberof PtpRuntime
int ptp_send_data(struct PtpRuntime *r, struct PtpCommand *cmd, void *data, int length);

/// @brief Try and get an event from the camera over int endpoint (USB-only)
/// @memberof PtpRuntime
int ptp_get_event(struct PtpRuntime *r, struct PtpEventContainer *ec);

/// @brief Unlock the IO mutex (unless it was kept locked)
/// @memberof PtpRuntime
void ptp_mutex_unlock(struct PtpRuntime *r);

/// @brief Keep the mutex locked one more time for the current thread
/// @note When calling a thread-safe function, this will garuntee the mutex locked, in the
/// case that you want to continue using the buffer. Must be unlocked or will cause deadlock.
/// @note camlib uses a recursive mutex.
/// @memberof PtpRuntime
void ptp_mutex_keep_locked(struct PtpRuntime *r);

/// @brief Lock the IO mutex - only should be used by backend
/// @memberof PtpRuntime
void ptp_mutex_lock(struct PtpRuntime *r);

/// @brief Gets type of device from r->di
/// @returns enum PtpDeviceType
/// @memberof PtpRuntime
int ptp_device_type(struct PtpRuntime *r);

/// @brief Check if an opcode is supported by looking through supported props in r->di
/// @returns 1 if yes, 0 if no
/// @memberof PtpRuntime
int ptp_check_opcode(struct PtpRuntime *r, int opcode);

/// @brief Check if a property code is supported by looking through supported props in r->di
/// @returns 1 if yes, 0 if no
/// @memberof PtpRuntime
int ptp_check_prop(struct PtpRuntime *r, int code);

/// @brief Mostly for internal use - realloc the data buffer
/// @note r->data will be reassigned, any old references must be updated
/// @memberof PtpRuntime
int ptp_buffer_resize(struct PtpRuntime *r, size_t size);

int ptp_write_unicode_string(char *dat, char *string);

0 comments on commit 0c05030

Please sign in to comment.